Real World Haskell

January 10, 2009 - zenoconsultingzenoconsulting


I picked up the book Real World Haskell by Bryan O'Sullivan, John Goerzen & Don Stewart. I'm still pretty early in the book. I've only made it through the first 4 chapters, but I have to say it is a fantastic piece of work. I'm trying to learn Haskell not because I think it will necessarily boost my resume or I'll get tons of consulting offers for knowing Haskell, but just because it is fun, and it provides me with a totally different way to think about programming. Not to be too cliche, but this "out-of-the-box" thinking can really help when you are faced with solving difficult problems. It helps to have a decent arsenal to draw from.

Did I mention Haskell is fun? Programming Haskell seems more akin to defining a mathematical formula; it is very brief and powerful. One liner functions seem to be the rule of the day. As the authors point out, getting the one-liner to pass the compiler test is usually a good sign that the program will work as expected. Contrast this with something like Java and OO where you build classes with state & behavior and have to write lots of unit tests to validate both state & behavior. Haskell state is immutable, so you don't have to worry about program correctness based on interactions at runtime. It is more like a mathematical proof. Once you've got it right with the boundary conditions, it should always just work.

The book is pretty hefty at 600+ pages, but it is written very well — lucid, forgiving on difficult topics, but not too repetitive that it gets boring. Reading it isn't really a sit-down exercise, it is an interactive adventure. You might try to just sit and read it, but you won't get too far before you decide to fire up the Glasgow Haskell Compiler (ghci) and experiment with the examples they are discussing. The thing I find so rewarding about Haskell is that it is mentally challenging, but not tedious like so many other languages. I don't need 5 different frameworks and specific IDEs and I don't have to write a lot of code to follow through on an example or experiment with the language.

Many other blogs have discussed one of the challenges with programming today: learning a language very well in today's environment just isn't enough. The average programmer has to also learn a myriad of various frameworks and how to apply them effectively. For example, I like Spring and Hibernate and Apache ActiveMQ, etc., and my bookshelf is filled with 500+ page-count books like these. I've invested a lot of time to learn all this stuff. It becomes a daunting task, and if you want to stay effective you have to keep up — it never ends. Sometimes it is nice to go back to something much simpler and learn a new way of thinking. Get back to the roots of computer science, mathematics, algorithms, etc. So, I divide my time equally between keeping up with the latest foo-bar framework and digging deeper into things like Haskell and Algorithm Analysis.

Back to the book…the authors also do a really nice comparative analysis between Haskell / functional programming vs. imperative languages and also statically typed languages vs. dynamically typed languages. These side-bars are strewn through-out and do a great service to the reader who is coming from a different programming world. You can see the pros/cons of various language choices. This is a nice thing to learn, again because it makes you a better problem solver when faced with a new task where the choice of language hasn't been chosen yet.

So, I also have Graham Hutton's Programming In Haskell. I haven't quite finished it. I buy too many books, and I dive into them without reading cover-to-cover :) To contrast, Hutton's book favors brevity, but it is still geared toward the newbie. It is more terse, but I don't want to take anything away from it, because I think it reads similarly…just with less information. I look forward to diving back into Graham's book after I've plowed through more of this one.

Finally, if you didn't know it already, Real World Haskell is available for free online. Try before you buy.


Add a New Comment
or Sign in as Wikidot user
(will not be published)
- +
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License