Thursday, March 14, 2013

What Programming Language Should I Learn?

I've seen this question pop up on various forums with disturbing frequency lately. Enough that I just wrote this so that I can link people to it instead of typing the advice out each time. The stuff I cover here has already been touched on in a post called Self Titled. Go read that if you want more perspective on my opinion, but it's fairly long so I need to put something shorter and more accessible together.

A Better Question

is "What do I want to do with my programming skills?"

If your goal is merely employment in commercial IT in the shallow future, then the answer is simple. You should learn C++. Then one of Java, C#, Objective C or PHP depending on what niche you want to work in. Then you should stop learning things. After a little bit of a grind, and as long as you're not a complete asshole, or idiot, or both, you'll get promoted to team lead somewhere. At that point you're not writing code, so it doesn't really matter what languages you know or how well.

That's it, you can go.

Pretend the rest of this article doesn't exist.

If You're Still Reading

your goal is to push the bleeding edge of Comp Sci/IT forward, and you have your work cut out for you.

If you're serious about this goal, then you need to understand something. Being a new programmer and asking "What language should I learn?" is roughly like being an aspiring carpenter and asking "Should I learn to use hammers or screwdrivers?". You won't get good answers because it's the wrong question. Usually, you get an avalanche of people coming in to push their pet language forward ("Definitely just stick to the hammer"), or to push the currently fashionable answers ("No one uses hammers anymore, learn to use a nail gun"), and you shouldn't listen to any of them.

Languages are tools, but they're not like physical tools. A language is not a bandsaw. It's the Theory of Relativity. A collection of cognitive tools and abstractions that help you think about unfamiliar and counterintuitive concepts precisely enough to explain them to very stupid machines, and perhaps to very inattentive humans. I say this because the askers of the big question often say that someone has told them something like "Blub is old; don't bother with it". That's not a valid argument against a language. Theories don't rust. Occasionally they're disproven, or revised, but merely being old isn't enough to discredit them[1].

If you want to be a brilliant programmer with a chance of impacting the deep future, sure, you need to understand how the underlying physical machine actually works, and C/C++ helps with that, but it's nowhere near sufficient. You need to really understand OO, which means spending a while hacking on Smalltalk or Ruby or Simula. You need to understand the different kinds of OO on offer, which means dealing with class-based systems (like C++/Java et al), prototype systems (JavaScript or Self) and generic-based systems (Common Lisp) at minimum.

You need to go beyond OO; understand functional and declarative programming, in both strongly/statically and dynamically typed flavors. If you just want a list of languages, that means a whirlwind tour of Haskell/Scala/an ML, a Lisp, Prolog or Erlang, and more than I can reasonably list here besides. It's probably a good bet to just look at the Programming Paradigms page on Wikipedia and read anything linked off the right sidebar, it's all relevant.

You need a thorough understanding of compilers, which you can get by putting a few years into really, truly understanding Lisp macros and/or reading the Purple Dragon book[2] and/or writing one. You'll need to know about data structures, both traditional and functional[3], about set theory, and graph theory, and probability theory, and advanced algebra and probably a hundred other things I missed. Including things that are only incidentally related to programming, like source control, human management/interaction, hardware maintenance, writing, security, typing and the social impacts of the work we do.

Learning to program is not a thing you pick up in seven days, and you could do a lot worse than to start by reading that article. Just make sure to also disabuse yourself of the idea that you do it by picking one language and sticking to that.

TL DR

So, in case you skipped directly to this line, the short answer is "all of them, and that's just for starters". Good luck; I'll see you on the other side.


Footnotes

1 - [back] -"Blub has an inactive community" or "Blub's community is principally composed of assholes" are valid arguments against using a language. But keep in mind that you can still learn a lot by understanding a language that assholes use, or that very few people decided to use. Also, keep in mind that the metrics related to these arguments are relative and necessarily personal; if you're close friends with five or six people who use Io, then it really doesn't matter much what the rest of the world is doing.

2 - [back] - If the price-tag scares you, I should mention that there's a way to get a softcover edition for something like $40, but it doesn't include the same exercise sections or cover and is printed on pretty shitty stock. That's what I ended up doing, and mine's still in one piece even after a few years, but I can't find the link to that deal anymore even though one of the customer images is that edition of the book..

3 - [back] - I'm putting the Amazon link there, but the first link in a google search about "Purely Functional Data Structures" seems to be a legitimate, free PDF copy of the same from CMU.

No comments:

Post a Comment