Haskell, haskell, haskell, haskell, mushroom, mushroom.

Haskell and Hack fanboyism.

I guess I'm a fanboy now. I try to be reserved when it comes to excitement over languages and frameworks - only gushing to close friends with "HOLY CRAP you've got to checkout X". I loved Rails until I had to work on it under heavy (>45m daily users) loads. My first love was CGI::Application with Perl and then later Maypole which became Catalyst. Then it was Erlyweb, Nitrogen, and finally BeepBeep in Erlang. I loved them all. I'll spare you the descriptive metaphor of ex girlfriends though it does sound like fun to write.

Anyway, I decided a few months ago to sit down and put serious effort into an idea that has been sloshing around in my brain for a couple of years. I looked over all of the past frameworks I have used and found them lacking in one respect or another. I have been learning Haskell over the past few months and decided to dedicate a weekend to testing the viability of using it together with an as of this time undetermined framework. The results are in, and wow. I think I'm in love all over again.

Hack is a haskell version of Rack, apparently. I had never even heard of Rack before I stumbled onto Hack, but I really like the idea. In a nutshell: it's what I call a frameworklet. The author does a much better job of describing it than I ever could. You can read about it here. Personally, I think it's the perfect Haskell web framework in that it's very small and gives you the tools you need without much else.

I'm sure it's debatable whether using a web project to learn a language is a good idea, but it's what I always end up doing. There's usually 3 operations that I want to learn how to do first before I feel I can do anything useful.

1. Parsing POSTs
2. Templates. I personally find generating HTML with code makes my code ugly and inelegant. My code is already pretty ugly and inelegant to begin with so this only adds to my pain.
3. Storage. A db, or K/V store. For testing my current project I'm using SQLite though I really do like CouchDB and, to be honest, I also like using memcachedb and I'm looking forward to sitting down one weekend and coming up with a module to maintain tables of contents and indexes for keys in an elegant way.

I'm planning on making a hackage package (!) of shortcuts for Hack in line with the Perlism of making a Module::Simple package. Here are some of the ones I'm using so far:





The application is almost done and so far it's a dream! Very very fast, small footprint, and handles a very respectable amount of concurrent requests. I'm anticipating that SQLite will be the first problem but we'll see what further testing reveals.

0 comments: