Will Roe's blog

Anaλysis Paraλysis » Archives

So I have started to learn Haskell (again - I learned the basics at university for the Functional Programming class and loved it, I have since forgotten most of that).

Haskell is weird

When you first start out learning this language - or even just read some articles about it - the first thing that will strike you is that it seems completely obscure. The syntax is obscure, the concepts are obscure, but most of all - the language used to describe what things are is incredibly obscure. Every programming language community has evolved its own lingo of course and Haskell’s is awash with mathematics. If you subscribe to the planet Haskell RSS feed you will get the impression that Haskell is pretty much just an extension of Mathematics and is only used for “pure” problems and therefore completely irrelevant to real world problems. Then you will notice there’s a book called “Real World Haskell” and you’ll think it an anomaly, just some noise in the data.

Why learn this?

Apart from wanting to become a better programmer in general (which would explain why I’d want to learn functional programming in general and in more detail than I already do from Erlang and Clojure), I want to learn how Haskell can be a practical language - how it can help me create great products. I suspect that behind the terseness and high degree of greek characters is a toolkit that will be at least as empowering as Erlang/OTP has been. I want that toolkit.

The elephant in the room

Sooner or later you will arrive at the Haskell trial stage. In order to print anything out from your programme, or accept any input or read a file etc. you will have to use monads. At first the syntax will seem very strange, just a load of terse boilerplate for doing what more pragmatic languages make super easy, but you’ll think “whatever, let’s just get on with learning this thing”. At some point the tutorial or book you’re reading will have to explain monads to you. More than likely this is the point where you stared at the screen/page in disbelief and your heart sank as you realised you would have to understand level 3000 mathematics to print something on screen. For most people, this is the last they ever deal with Haskell.

Later on, a Haskell wizard will act all puzzled and amused that you found monads hard to understand. This will lower your self-esteem so low you consider giving up entirely and becoming a farmer instead. They will go on to tell you that you’ve been using monads the whole time in whatever programming language you like. They will explain how this is so and you will not be enlightened. It’ll sound all too convenient, just a bunch of semantic drivel.

The reason so many of us have such a frustrating initial experience with Haskell is that most of the books on the subject are appallingly badly written. Programming books are in general a complete shambles and very few are useful to anyone who isn’t already pretty hot at the whole thing anyway. If you were lucky enough to find a well-written helpful introduction to Haskell (there are some), then you might not be feeling this way. Also if you were born a Haskell wizard, this will sound like complete gobbledegook to you. But then you’re not really human now are you? Admit it.

Anyway, I will be attending the Haskell hoodlums meetup this Thursday so hopefully I’ll start understanding this thing. Don’t give up people! Good luck.