Programming Languages

Programming Languages

You choose a language for day-to-day programming based on its libraries, documentation, tools support, OS integration, resources, and a host of other things that have very little to do with how computers work, and a whole lot to do with how people work. - Steve Yegge

Languages shape the world. Dumb languages make for dumb worlds. - Steve Yegge

Familiarity breeds contempt in most cases, but not with computer languages. You have to become an expert with a better language before you can start to have contempt for the one you’re most familiar with. - Steve Yegge

A language that doesn’t affect the way you think about programming, is not worth knowing - Alan Perlis

Programming languages are actually for people

That’s the thing about programming languages: They are actually for people; they can’t just be parsable by machines. In the classic textbook Structure and Interpretation of Computer Programs, the authors make this clear:

Thus, programs must be written for people to read, and only incidentally for machines to execute.

How long does it take to learn a language?

Bjarne Stroustrup invented C++. There is a video of him answering the question “How long does it take to learn C++”. This is based on that interview.

Depends what you want to do and what you already know.

If you are already a programmer in quite a few languages, my recommendation is to read the Tour of C++. You can do it in a weekend. And now, you have the fundamentals and you have to do some experimentation and probably dig deeper in into the areas you’re interested in. If you want to do anything, you have to pick up some libraries and learn them. We’re talking days or weeks. But that assumes you’re a programmer. If I have to explain to you what a linked list is or what a vector is or what a hashtable is, then it takes much longer. So if you start from the beginning to reach the professional level, we’re talking months and years. And one question sometime ask is how long does it take to play a violin? To learn to play a violin? Well, if nobody’s listening, it’s easy. If only your mother has to appreciate it, maybe it’ll do fine. But otherwise, it’ll take years. Now, if you’re already a violinist, and you want to play a viola, you can probably do it in a couple of weeks.

Depends what you are, what your background is, what you already know, and then how good do you want to be at it.

If you’re if you’re thinking about the Lincoln Center, you better spend years.

Reaction from The Primegean:

I feel like he’s probably right. Learning C++ with prior knowledge, it probably just takes a couple weeks, a weekend and all that. But learning to read someone else’s C++ in which they’ve been writing for like a decade, it’s going to take a long long time. I remember being okay at C++. Meaning, that I can mostly do all the things in it and I was pretty okay. This is when I was doing a lot of active development in it just a couple years back. I was doing a whole bunch. And I felt pretty happy about it and then I go to look at this logging class that was set up and I spent three days debugging through the logging class, GDB, printf. I even got seedlion out to try to help me on this thing. Never understood it. Literally spent a about 40 hours looking at code and never figured out how it works. I couldn’t. I couldn’t. I just don’t know what voodoo magic I was missing. But this dance between macros, and then code, then that the code, then enacts more macros underneath, like that dance, impossible. When you get Macros, templates and code together, it’s going to take you a long time. Long long time. There’s a lot of inheritance too.

Bjarne:

The equivalent for a programming language.

If you want to be the ace programmer, building the Next Generation infrastructure or the next absolutely great application, you better spend some years learning, not just the programming language but your basic computer science and your application areas.

The Primegean:

I think one thing that he doesn’t quite talk a lot about in this, I know it’s very really short video, but something that he doesn’t address a lot of is that,

It’s one thing to know the language and what does it mean to know the language. Like you can use what x percentage of its features, 70 percentage of the features, 80% of the features, without having to look them up, like you can kind of recall them and basically use them. But what does it mean to actually know a language? There’s also kind of like a Zeitgeist or an intended usage of a language. And that intended usage takes a while to become like to really get. Just because you understand how to write the language does not mean you actually know the language at all. Just because I could write say lines of JavaScript, doesn’t mean I am a JavaScript programmer. Even if you can write entire applications in JavaScript you may not actually know how to use it correctly. And it’s also really hard to know how to use a language correctly that you can do it in many different ways. And so, C++, JavaScript and Rust, all suffer from this exact same problem, which is that there’s like tons of different ways to solve the exact same problem. And I find that to be a really difficult language to truly understand. Because as time goes forward, you could go into someone else’s project as an expert and be completely just befuddled by it by how they chose to program it. It’s massively different than how you would do it. And it becomes just like it can become a very confusing thing. So many ways to do stuff. Heavy abstraction. Easy to do that. And JavaScript has the same thing. The only difference is Javascript abstractions are often runtime abstractions, as opposed to compile time. And so it’s very difficult. That’s one reason why I’ve been really just appreciating this Go journey. Is that the Go Journey. There’s just really kind of like two ways you can do it. And it’s beautiful.

Evolution of programming languages

Coding has a rich history of The Olds saying that The Youngs have it too easy. That’s assembly to C and it’s C to Java, and it’s Java to Ruby.

If you go back to the rise of C, you can find assembly language programmers lamenting the loss of granular memory management. If you go back to the rise of Python/Ruby, you can definitely find C programmers lamenting the loss of manual memory management. If we lament all the things you lose from vibe coding – is it the same thing? Are we the old person yelling at the tides?

Features to look for when looking to learn a new programming language

This will give an overview of the practicality of the language.

Questions to ask about the language:

  1. Is it easy to use?
  2. Is the language empowering?
  3. Is it rewarding to share with others?
  4. Would you suggest to other people to learn and use it?
  5. How does the language handle garbage collection?
    1. Not just theoretically?
  6. How does it compare to other languages like C++, Java, Haskell in a production environment?
  7. Write some examples to get a feel for the language
  8. Implement using custom ssl certificates. See the differences in the ways this is handled by various languages. This process is handled graciously in some languages and it is a painful process in other languages.
  9. Verify concurrency
  10. How good is the cloud support for these languages? For example, CloudFoundry offers good (in some cases, custom support) support for Java and NodeJS based applications. What happens if we want to use other languages for applications?
  11. How are the tools for this language? Look at the tooling for those languages
    1. Docker images
    2. Working with pipelines
    3. Deployments
    4. Monitoring/Observability
    5. Testing
      1. Integration tests (with databases and other backend services)
      2. Unit tests and Code coverage reports

Feature comparison tables

Between OCaml and Haskell

Feature OCaml Haskell
Expression-oriented syntax
Immutability by default
Higher-Order Functions (HOFs)
Anonymous functions (lambdas)
Algebraic Data Types (ADTs)
Pattern Matching
Parametric Polymorphism
Type Inference
Monadic Syntax Sugar
Garbage Collector
Multithreading
GADTs
Purity by default
Composable laziness
Type classes
Higher-Kinded Types
Opt-in language features
First-class modules
Polymorphic variants
Objects
Classes and Inheritance
Ergonomic mutability

Tooling comparison tables

Between OCaml and Haskell

Tool OCaml Haskell
Compiler ocaml ghc
REPL utop ghci
Build tool dune cabal, stack
Package manager opam cabal
Package repository opam Hackage
Toolchain installer - ghcup
Linter zanuda hlint
Formatter ocamlformat, topiary fourmolu, stylish-haskell, hindent, ormolu
Type Search Sherlodoc Hoogle
Code search Sherlocode Hackage Search
Online playground TryOCaml Haskell Playground
LSP ocaml-lsp HLS

226 156 133

Learning resources

github.com/janestreet - They seem to be doing a lot of interesting stuff with OCaml. It would be worth spending time looking at their stuff if we need to get a better understanding of Ocaml.


Links to this note