Inspired by Pragmatic Programmer's "one new language a year" and this series of posts I have decided to take up the challenge.
Now I know I will not be a competent programmer in this new language within a year. It takes years to become competent, decades to become a master. But fooling around with a new language in my down time will certainly expose new ideas and concepts.
But which one?
There are a lot of programming languages. The real question though is
What do I want to get out of this exercise?
And there is a really simple answer to that. To learn. Not to jump on the hype bandwagon, not to compliment my existing skills, not to learn a new syntax. To really learn. Learn new theories and paradigms. To make my brain hurt. To get those light bulb moments after days/weeks of re-reading and experimentation.
Based on this I decided I should learn a functional language. I have several years’ background in imperative object oriented languages such as C# and Python. And the king of functional languages is Haskell. So that's what I should learn right?
Well practicality persuaded me to actually do a little research. This article came across reddit recently and I think it is a good practical comparison of the more popular general languages. What surprised me was OCaml's position as very fast with high expressibility.
I am also intrigued by F#, especially since I saw a good talk on it recently and it is becoming a first class .Net citizen with VS 2010. However, seeing as it is based on OCaml, and I prefer to develop on a Mac, I figured OCaml would be a better choice over F#.
This brought it down to two choices.
Haskell or OCaml
My rough and dirty criteria are:
- Installers for OS X and Windows as I use both quite regularly. By virtue this means cross platform as well.
- Text editor/IDE integration. I can use vim, but I prefer tabbed GUI style interfaces.
- Libraries. I don't want to re-invent the wheel all the time.
- Availability of books and online tutorials etc.
A quick comparison of the two sees that they are both available via MacPorts, although OCaml requires some other packages as well and both use Cygwin on Windows. Cygwin is not optimal but definitely workable.
OCaml has an Xcode plugin which unfortunately does not target Intel processors and seems to be in perpetual beta.
Both seem to have great support in the usual suspects of vim and emacs. Both my usual text editors (TextMate and [NotePad++]) support Haskell out of the box but not OCaml.
Haskell it is
The real clincher for choosing Haskell was this answer stating that Haskell seems to better looked after in terms of libraries. This combined with resources like Learn You a Haskell and Real World Haskell validated my initial assumptions.
Besides, the O in OCaml stands for Objective. OCaml being a cross paradigm language could make it all too easy to slip into comfortable styles and structures rather than force myself to really understand the functional paradigm.
The Plan
First off I intend on working through Learn You a Haskell in conjunction with trying out Project Euler before delving into Real World Haskell.
If all goes to plan, I should finally know what a monad is...
Don't waste your time learning obscure languages. I can write equally bad code in several dozen languages. Instead learn algorithms, data structures, AI, compilers, graphics, etc. in any language.
"I can use vim, but I prefer tabbed GUI style interfaces." - If you use gVim, you can have lots of tabs. Moreover, you can have multiple windows inside each tab.
I'm glad I inspired you. I will definitely be doing haskell next year. My main lesson that I've learned so far is that you really need to find something that is interesting to you and will keep your interest for the long haul. I think it really helps if you have reason to believe that what you are learning will either be useful day to day or is just addictively fun.
In the vein of euler problems I'd also recommend looking at: http://haskell.org/haskellwiki/99Haskellexercises
@projectshave: It is precisely the reason that I am learning a functional language. Not to learn some obscure thing, but to learn new techniques and theories.
@dustbunny0: I'll be sure to check them out.
I'm not sure your blog comment Turing test is valid, but what the hell ...
ProjectShave has a point about learning all those dry & tedious things that I ought to have crammed more into my head at university. But the point of learning a new language is to think outside your preconceptions; and surely learning to write a compiler is kind of going down that language-learning road some way ...
I'm keen to dabble in Lisp because of the expressivity og the language but also because of the quality of the minds I am seeing who write in it. (Paul Graham has a first class arts-technical mind, but Peter Norvig would win me over if Graham didn't.)
But why not go further, since this is out of hours stuff, and write your own domain-specific language? I'm having all kinds of fun playing with that ...