March 23, 2017

What programming language should I learn? (2017 edition)

I occasionally find someone asking this question in my inbox. I’ve learned that for every person that bothers there are a bunch more with the same question, so I thought I’d take a break from relentlessly plugging my side hustle Later for Reddit to answer it publicly.

(Apologies to the most recent guy who asked this, because I’m copying and pasting large sections of this post from my email reply.)

Just starting out? Learn Python.

As far as I’m concerned, there’s exactly one right answer here. Python is an astonishingly well-designed language. The syntax is simple but effective, the performance is good enough for most tasks, the standard library is probably the most batteries-included of any language, the significant whitespace forces you to format your code as you ought to be doing anyhow, and yet it’s still flexible enough to get weird with

After you pick up a bit of Python, you can branch out in a few directions. Ruby is quite similar, and you wouldn’t be ill-served to try it out. Java is a bit harder on your carpal tunnels than Python but is still increasing in importance after some 20 years.

Desperate for work?

If you want to do anything involving the internet, learn Javascript. Just be careful – despite looking familiar, Javascript is a very quirky language indeed, which is why I wouldn’t recommend it as a first choice.

If you want a serious job with a serious company, learn Java (an almost-completely unrelated language). Just enough to write a basic HelloWorldPrinterFactory class, you can pick the rest up on the job.

Ultimately, learn both of these. Java is almost essential for high-throughput server software, and half the people who are shouting counterexamples at their monitors right now were going to name a JVM language anyhow. As for Javascript, it’s getting harder and harder to get by knowing no JS – even tooling is starting to come Javascript-flavoured, and you might want to get a handle on some of those quirks I mentioned before you have to deploy it in production.

Got this far and don’t know C? Learn C.

If you are a professional programmer but don’t know C at least well enough to read and understand it, you will probably feel a vague sense of shame about this fact. You are correct to feel so, but don’t be discouraged. Knowing Java or C# will get you a lot of the way there, the rest is just pointer arithmatic and manual memory management, which you should absolutely know how to do just in case you need to someday.

C++ is a fine language, but nowhere near the mandatory level that C is.

Want low memory consumption and high performance but don’t want to write C?

Try Go or Rust.

Tired of OO and want to try something functional?

I highly encourage any developer to try them some functional programming. But, as has been pointed out elsewhere, “functional programming” probably puts the emphasis in the wrong place, since a lot of modern functional programming techniques emerge as an effect of working with immutable data. A nice side effect of this is that immutable data structure implementations exist for many languages, and once you know how to wrangle them in one language you can do it anywhere.

I’m a well-documented fan of Clojure. It’s still my weapon of choice for personal projects. Clojure has some nice performance characteristics over Python and other dynamic languages, especially with the core.async library letting you do go-style CSP concurrency, but still maintains its brevity. It also has the best utilities for working with immutable collections of any language I’m aware of.

Haskell is also a very good language to know. It takes some effort to intuitively grasp the whole type system, but once you do you’ll miss that surity whenever you use anything else.

Other options for educational-but-esoteric languages include:

  • OCaml
  • Erlang
  • Elixir (Erlang meets Ruby)

The final answer: It doesn’t really matter that much.

Software is software. Different languages and libraries and runtimes and virtual machines and compilers and other such things will expose different tradeoffs, but in the end your choice of language is secondary to your ability to solve problems in a way that a computer will understand. You can pick up the rest on the way. (Another plug: try Learn X in Y Minutes for a quick primer on just about any programming language.)

If you ask me, your end goal is to get to the point where language is no obstacle – every language is some combination of other ones, and the more languages you’re familiar with, the greater your head start picking up a new one. As long as you’re learning something new, or trying to do things differently, you’re headed in the right direction.

A special message

This is where the affiliate links live, but hear me out! I use these two services every day, and I wouldn't recommend them if I wasn't satisfied.

DigitalOcean - Purveyors of fine (and inexpensive) virtual servers. I use DigitalOcean to host Address Bin and a few others; it's my go-to host. Use this referral link for a $10 credit.

AirBnb - I've been living in AirBnbs for over a year now, and plan to for many more. If you've ever wanted to try them out, you can get a $25 discount from this referral link.