Dive into Erlang

So after mucho procrastination I’m finally diving into Erlang. As I’ve said many times before, the new cloud-based web platforms such as Heroku and AppEngine are great for rapid development of simple webapps, but are lacking if you want to do any serious data gathering or hardcore calculations at the back end.
Some initial observations:
Compilation is a serious barrier to rapid learning. If you come from the Ruby/Python web world you’re probably used to typing little snippets of code into the interactive prompts, and seeing what happens. Erlang has an interative shell, but you have to compile files before you can run then. Unfortunately this simple shift from a one-step to a two-step process seems to really mess with my productivity – I just don’t seem to get the quick feedback my brain needs to get the concepts to stick. I’d recommend setting up a Rake file to compile/run target files in a single step – so you can call ‘rake run whatever.erl’ and get that nice quick feedback loop going.
The language reminds me a lot of Python, particularly the heavy use of anonymous functions / functions as first-class objects. Also the libraries don’t look too bad; there’s stuff in there for HTTP clients, HTTP servers, XML parsing, JSON parsing [with Mochiweb], regex; nothing the absence of which would be a deal killer for web programming.
Immutability doesn’t hit you over the head I had thought that moving to a ‘true’ functional language would require a major change in programming mindset. In fact for the most part you can carry on programming as normal, occasionally bumping up against a proverbial wall [why can't I create a loop with a counter variable ? why does updating a dictionary cause a brand new dictionary to be created ?] You then reflect awhile on why that wall might exist, and why your previous assumptions regarding loops/dictionaries/[insert favourite feature of choice] might not have been very heathly. A month ago I couldn’t have told you what a side-effect free language meant or implied. I’m not there yet, but I start to see the benefits – in particular why you need to ban side effects in order to parallelise your code properly. But in the meantime, it’s nice that Erlang introduces these concepts to you gradually.
Concurrency support is a real eye-opener I’d never really considered that processes could be baked into the language rather than the operating system – now of course it makes perfect sense. It’s worth spending some time building sample servers from first principles, at least so you have some idea of what OTP gen_server is doing – see Joe Armstrong’s book or Kevin Smith’s screencasts, both highly recommended.
OTP / Mochiweb could be my replacement for Rails. OTP seems to have good support for distributed processes, error handling, logging. Mochiweb contains a stripped down HTTP server, proper JSON support, and a Rails- like project generation script whose results seem to be OTP-based. There’s still some work to do [which template engine ? which persistence store ?] but I think the combination of the two might provide the Rails replacement I’m looking for, with the all-important support for distributed processes.
Plenty more work to do. Next step is to setup a Mochiweb sample project and see if I can replicate a simple Rails CRUD scaffold.





