I’m going to try writing a balanced post about a programming language. Meaning that the words suck, shit, moron and brain dead are prohibited. Enterprisey too. And scale.

I’ve been mucking around with Haskell for some time now, enough to know my monad transformers, functors and function composition. It’s all serious shit. Ooops, sorry. So I won’t lie to you: the learning curve is steeper than for most other languages I’ve learned before and I already have some decent functional programming skills. The purity of Haskell brings lots of advantages but it definitely requires more brain power than Java (random example). You also write at least twice less code than Java (another random example), in terms of terseness it’s close to Ruby and can arguably be more expressive.

Now don’t let the apparent complexity put you off, I’m just warning you a bit, you’ll have to stay focused to learn Haskell, but it’s still very reachable and most importantly (spoiler alert) it’s worth it.

The Community

Haskell enjoys a really nice, helpful community. That might explain their unofficial slogan (“avoid success at all cost”). The landscape would probably change a bit if the language became mainstream. The #haskell channel on freenode irc is pretty amazing for a relatively small community: it’s actually one of the largest around (they’ve beaten a record of some sort recently). You can pretty much always find a nice person to answer to your dumb questions, whatever your timezone.

Then there’s the Haskell Cafe mailing-list with similar qualities. The traffic is medium, trolling quasi inexistent and interesting subjects being discussed daily.

My only reserve in the community section (hey, I have to say at least one negative thing, right?) is that there’s still a very present academic stance. You’ll see a few conversations turn to category theory geekness. A lot of the libraries documentation is actually publication papers (pdf warnings). I don’t really find it annoying (except for the pdfs), it’s a nice change from the enterprisey (did it again) world. But YMMV.

Finally there’s a truly awesome book, Real World Haskell, to get started with the language. It may very well become an equivalent to the pickaxe in Ruby.

The Implementation(s)

Again, Haskell shines here. The compilers are really top-notch, nothing less. The reference is GHC but there are a few others and initiatives trying to out-GHC GHC. You can both compile code to an executable or have it interpreted, which makes experimentation much easier. The point is, there’s a strong ecosystem and most of it is production quality. No noodling here, just good software. Really.

And one of the sweetest thing I’ve found about Haskell is that the produced executables are pretty damn fast, especially for a high level language. To a point where you have to wonder why you would use anything else when you’re trying to optimize for performance. I can tell you, the Haskell experience beats hands down the C++ or Java experience.

The Language

Finally, I can fully indulge in my programming language geekery. So if you followed the first link I used for Haskell, you should know that it’s a pure functional language. It’s not its only important characteristic, far from it (personally I like partial application a lot), but it’s probably the one that had the biggest influence on the rest of the language. One of the consequences is that Haskell relies heavily on monads to model state (and not only that). Explaining monads is not the scope of this post, if you ask me they actually shouldn’t be explained, just experimented with. But the consequence is that Haskell is almost two languages in one. You have the “pure way” of programming and the “monadic way” of programming (and please, if this gives you a knee-jerk reaction, read on).

The “pure way” is like a honeymoon: it’s all beautiful, really. You have partial application, function composition, pattern matching, higher order functions, type inference and it’s all boundless. Once you get used to it, it’s like brain candy.

The monadic ways is more like 5 years after the honeymoon. Don’t get me wrong, I’ve been happily married for more than that. It’s just more an age of pragmatism. You have to build on top of all past decisions, work, lifestyle, … And you can’t always live in a honeymoon, there are other important stuff out there. Like hard disks, network and users (that’s where the metaphor breaks). So the “monadic style”, even though it works well is still terse and pretty sweet, just isn’t as beautiful.

Now you have to realize that my last two paragraphs were purposefully Manichean, I just wanted to give you a feel of the difference. Practically, it’s far from being so black and white. “monadic style” is more like an embedded DSL (it’s actually just a lot of syntax sugar), you can still do all the nice stuff like currying or composing monadic functions. Most importantly, it all feels like Haskell.

Writing a single section about the language is actually slightly painful, I feel it deserves much more. But that will be yours to discover. Believe me, you’ll enjoy the expressive power.

Conclusion

Haskell is now one of my favorite programming languages, sharing the spot with Ruby and Scheme (Javascript is close by). I’m not saying it will fit every purpose better than any other language, all programming languages have their respective sweet spot. But overall, I’m really damn happy to have Haskell with me in my toolbox.

Update: in the community section, I should probably add that Haskell has a very large ecosystem of libraries called Hackage. Hackage integrates a package manager (because you can never get enough of them) that makes installation rather straightforward. Now you know how to get a Haskell Tetris!

Image creds: martinlabar and arielarielariel.