Friday, April 4, 2008

Learn as Many Languages as You Can

Nick Plante recently reminded me in his blog of the advice in Pragmatic Programmer to learn one programming language a year.

I say why wait? If the Sapir-Whorf hypothesis has any bearing on computer programming (which I believe it does) then you can give your programming skills a big boost by cramming a bunch of languages in your head now.

However, you need to leave your safety zone and learn a properly disjoint set of languages so that you can effectively expand your thinking, and deepen your general understanding of programming.

Assuming like many of us you are of a predominantly C++/Java background then I recommend learning the following languages in roughly the following order, and as quickly as possible.

Ruby - Ruby does a great job of showing how powerful a dynamic language can be, and leverages powerful ideas from Smalltalk, Perl, and Lisp.

Scheme - Scheme is a dialect of Lisp with some pretty hardcore implementations. Make sure you can wrap your head around call/cc and be sure to learn what "lambda" does and what the different "let bindings" are for.

PostScript - PostScript is a neat way to experience the power of stack-based programming. It looks like a toy but it isn't, millions of printers around the world run it all the time.

Prolog - Prolog can make solving a large class of programming problems a snap to solve. It is also easy to implement in your language of choice.

ML - ML is one of the favourite languages used by computer scientists. I suggest learning algebraic data types (sum types and product types) then to move on quickly to Haskell.

Haskell - I find Haskell makes the most sense only after knowing Scheme and ML. Go crazy with pattern matching, but avoid using monads unless absolutely neccessary because they are cheating! You will be sorely tempted to resort to using them all over the place.

Erlang - See how easy distributed programming can be.
Getting some experience in this set of languages as soon as possible, would really catapult you forward to a new level of programming. You will gain new insights into solving programming problems in whatever language you happen to be using. It will also make transitioning between languages a snap.

Of course, not everyone has the time to or energy to learn a whole set of new langauges. So if you have to choose only one new language for the time being then my recommendation is Scala. Scala is very accessible to programmers from different backgrounds. Scala provides access to type inference and advanced techniques used in languages like Haskell, but still supports common Java idioms and dynamic programming.

The Scala by Example [pdf] online book for example was heavily influenced by the the famous Scheme book: Structure and Interpretation of Computer Programs. The fun thing about Scala, is that you can slowly introduce yourself to new concepts and still be an effective programming using a programming style that you are more accustomed to. The more time you spend with Scala, the more you realize that you can do with it, and it can take you quite far.

For the highly motivated, I have compiled a list of URLs at http://www.plre.org/languages.html of roughly a hundred programming languages if you want to survey the landscape of programming languages more thoroughly.

No comments: