Book: "Programming Elixir"

qr-code for this page's url

Recently there was yet another half-price offer by Pragmatic so I stacked up on a few books I always meant to read.

Erlang was always something that interested me (although it feels a bit awkward in its handling of records and strings and its main allure lies in OTP which is basically so big that you need to commit a serious amount of your life to this in order to make real use of Erlang), so I was quite interested in Elixir which got mentioned on various podcasts recently, and Dave Thomas's book "Programming Elixir" sounded like a good introduction here.

The book is aimed at people who know how to program (yay! at last not yet another few dozen pages wasted on how to set things up and tell you what an if statement is) but are so far unconvinced or even unaware of functional programming with immutable data. As such, the books spends a bit more time in the introduction trying to convince the reader about this than I would have liked.

The syntax is a bit weird to the uninitiated reader. My understanding is that it might less surprising if you have a background in Ruby but it doesn't help that in general there is a short form for any expression and a longer form which seems to be when you need to group multiple expressions. So e.g. either of these two expressions do the same although they look subtly different:

if someexpression, do: something

if someexpression do

Naming conventions differ so you Elixir module names are quite distinct from Erlang module names (which you can still use) so the Erlang interop while totally there is not quite as seamless as it might be.

But otherwise the language seems more enjoyable than Erlang. There are the usual (immutble) data types you expect, simple syntax to create anonymous functions, macros to extend the syntax to match your needs and the full Erlang-interop so that you not only have access to OTP but there are even some extra convenience macros to simplify use of the more frequently used behaviours such as gen_server, and there are protocols that you know from e.g. Clojure.

I myself am still a bit wary of Erlang and its runtime. A few years back I was running my own XMPP server which at one point suddenly failed to start up with pages of incomprehensible error stack traces about some problems with an mnesia store. I never managed to understand the errors, nor fix the problems and just gave up starting with a fresh server installation.

But overall this looks like a fun language to try if you want to get into the whole Erlang and agent based world and this book is a good introduction to get you started.