I have a confession to make.
One piece of the Pragmatic Programmer's advice that I often echo to other programmers is to learn a new programming language every year. Well, 2007 is done, and I let it go by without learning a new language. It's time to correct that, so I've decided to really dive into Haskell.
Why Haskell?
I'm not deluded enough to think that I'm going to be using it any time soon (if at all) in my day-to-day work. In fact, I'm skeptical that it will be useful even for my after-hours projects. However, I don't think that any other language can currently be more effective at teaching me general programming concepts.
Here are some of the concepts I'm hoping to grok by learning Haskell:
- lazy evaluation
- monads (and more general category theory)
- software transactional memory
My approach to learning Haskell
My main resources for learning Haskell are guides I've found on the web. Haskell for C Programmers looks like it will give me a decent overview, and from there, I expect to jump to A Gentle Introduction to Haskell. About a year ago, I read a little gem of a book called Purely Functional Data Structures. While that book uses Standard ML for its examples, it provides Haskell examples in the back. I also intend to work through the tutorial "Write Yourself a Scheme in 48 hours", which shows you how to implement a subset of Scheme in Haskell.
To be honest, I expect to have less difficulty learning the language itself than figuring out how to get anything done with it - learning what libraries are available and how to use them, learning how to best setup my environment for rapid development, figuring out the best way to deploy a Haskell application, etc. In my experience, these things are the toughest aspects of moving to a less-mainstream language. For example, even if you can find a library that does what you need, if it is not well-documented, you'll have difficulties finding usage examples on the web. And because it's less-used, libraries are more likely to be buggy or incomplete. And frankly, learning this stuff is a lot less fun than learning a language itself, so it seems to be even more effort than it really is.
As a starting point, I'm lucky that Paul Brown has just done the same thing (rewrite his blog in Haskell) and has some useful writings about the process. My first steps have been to get FastCGI working with Haskell, and that was pretty straightforward, thanks to Paul's post on the subject.
My approach to implementing the blog
At this point, I plan to use lighttpd with FastCGI for the web portion. I'm familiar with both from the time when they were your best bet for deploying Rails applications. I'm not sure what I'm going to do about the stuff a web framework typically gives you (URL routing, reponse templates, etc.). I'm just writing a blog here, so I don't need anything fancy, and I'm not too concerned.
I'm also not sure what I'm going to do about persistence, but I'm pretty sure I'm not going to use a relational database. Getting Haskell to talk to a database seems to be a tripping point for plenty of people who have tried what I'm attempted, and I don't see the relational model as being appropriate for a publishing system anyway. I'm toying with the idea of using CouchDB for persistence, since I think JSon is an appropriate data format for exporting my current data, and getting Haskell to talk to CouchDB should be straightforward since I'm sure there's a decent HTTP client library available. However, it may be more appropriate to just use the filesystem (which is what Paul did). We'll see.
Whatever I do, I intend to blog my progress, there seems to be a growing interest in Haskell along with a scarcity of practical guides to getting started. When I hit a roadblock that takes me hours to get past, knowing that I could save someone else the same frustration will make it more tolerable (I hope). Updates will be slow, though, since this undertaking is competing with at least 2 other projects for my after-hours time. I'm looking forward to it - from what I've seen of the language so far, it possesses a beauty that surpasses even Ruby. I can't wait to see if it still looks beautiful after trying to actually use it.