17th
Erlang Thoughts For Now
Well, we’re close to launching the thing I’ve been writing in Erlang, and I’m thus moving on to doing some work with Hadoop (my job rocks, is what I’m saying here ;-).
Few wrap-up thoughts as I go:
Overall, very happy with the experience. If you’ve got interesting concurrency, distributed programming and/or high availability problems, I think Erlang is very, very much worth your time. It makes things which are profoundly difficult in other languages surprisingly clean and easy.
Wondered if I would find the no-mutable-state thing an uncomfortable straitjacket, but I pretty much didn’t. (I’m probably somewhat atypical, to be fair, since Lisp was a formative early language for me, and functional thinking has always felt pretty natural — but I do use mutable state in python all the time, quite happily). If you need mutable state, you can get it by writing a little separate gen_server module, which is very easy to do (and then, by magic, you can start to take advantage of multiple cores more easily). Or you can use ets.
In this (and many other, important ways ;-), Erlang is nothing like Haskell, where you seem to need some kind of dispensation from the church to work with mutable state (if you want to hear Dan rant about Haskell, just say the word).
Overall, I think Erlang has two of the most important virtues a programming language can have: it feels simple, and it’s been used heavily in the real world.
Few specific hits and misses:
Hit: eunit. I can’t say enough good stuff about eunit. My learning arc was much like my learning arc with python — everything was easy to get started, and then I gradually realized there was tremendous power and flexibility under the hood. Go ProcessOne guys, go. And it’s also an excellent example of how you can write DSL-style code. Just, really great stuff.
Miss: strings. Arg. Lots of bits of my code have to obsessively check if they’ve been passed a binary or a list (= string), and if I forget to do that, it throws up all over the place. This did not get less frustrating with time.
Hit: mochiweb. Although there is, like, no documentation, it’s a very nice set of modules for building your own custom web server applications. Which is what we were doing.
Minor Miss: the strange mix of line termination/separator syntax. Thanks to emacs, this wasn’t too much of a pain, but it wasn’t great. But pretty minor.
Slightly More Major Miss: the fact that you can’t call methods on objects. As in, to look up a value in a proplist, you’ve got to call proplists:get_value(Key, Proplist). Instead of, say, Proplist:get(Key). It ends up being a lot of extra typing, you have to remember the argument order, and it makes it very hard to just swap in a new data structure.
Even More Major Miss: records. Man how they suck. If you could add a built-in functional mapping/dict type, with a literal syntax, it would be such a huge win.
Hit: OTP. Both the fairly comprehensive library (see real-world use above), and also the system for putting together applications.
Miss: lack of documentation on OTP in Joe Armstrong’s otherwise very solid book. He walks you through setting up a basic OTP app in late chapters, but doesn’t touch on a lot of key facets of the whole powerful but somewhat forbiddingly complex system. I’ve downloaded the OTP Design Principles docs, but it’s not always easy to figure out how people actually use those design principles. E.g. do you really need separate boot files? When? What’s involved in rolling out a release? How do I best manage / supervise apps on multiple nodes? Etc. Maybe I’ll learn more about all this as we deploy the system I’ve been writing, but I would sure be happier if Joe Armstrong had been able to write 2-4 chapters more on how to use OTP in the real world.
Hit: the Erlang Questions mailing list. Lots of responsiveness from impressive Erlang guys, both within Ericsson and outside of it. Feels like an early, small community, if that makes sense. Love that feel.
Anyways, I’ll leave it there for now. Had a great time so far, look forward to doing more. If you have any specific questions, feel free to leave ‘em in the comments…
-Dan M

