Book review: Programming Erlang

Concurrency is hard. A language’s implementation of concurrency concerns can make the challenge of dealing with concurrency even more difficult or a bit easier. Case in point: Erlang. Erlang is a hip functional language, developed by Joe Armstrong of Ericsson in the 1980s that explicitly facilitates concurrent programming by enabling distinct parallel processes (as opposed to threads) which communicate via message passing (rather than shared memory). Thus, in Erland, there are no locks or the need to declare synchronization as there is no notion of shared memory, like there is in Java (or C#, for that matter).

The question then remains for those who are Java developers: why should I care? For starters, because it’s my bag, it is undoubtedly interesting to see how Erlang is so vastly different than everyday Java. Not only is the language functional in nature (like Haskell), but it’s also type-less (that is, types are inferred at runtime like with Ruby, for instance). Because the language was built for parallel computing, it does some interesting things that have correlation back to Java– for instance, in Erlang, all variables are essentially final once declared. Thus, Erlang doesn’t support mutable state. As anyone who’s ever coded in Java knows, mutability, while intrinsically supported by Java, can easily create nefarious defects, even in non-threaded code.

But I think the author, Joe Armstrong, does a great job of stating why one should care about Erlang. In chapter 1, a rhetorical question is posted asking “what all this about?”– Joe’s response sums it up quite nicely:

It’s about programming a distributed concurrent system without locks and mutexes but using only pure message passing. It’s about speeding up your programs on multicore CPUs…it’s about designing methods and behaviors for writing fault-tolerant and distributed systems. It’s about modeling concurrency and mapping those models onto computer programs…

All in all, I enjoyed this book– I certainly learned an interesting language that has a long history of production use. It’s a big book (500+ pages including documentation) and I did find myself skipping a few chapters here and there– for instance, there is an entire chapter devoted to a custom database developed for Erlang (my thought being that if I need a database for an Erlang application, I’ll use a language bridge to leverage an everyday RDBMS).

Learning a new language is always helpful, man; in fact, I took my own advice, as I wrote years ago, those that learn new languages:

travel the IT world more freely than do monolinguists (sure that they can apply their skills in any environment), and they also tend to better appreciate the programming language called home, because among other things they know the roots from which that home is sprung.

Next language to learn? Scala, baby!

Post to Twitter

Related odds and ends
 

6 Responses to “Book review: Programming Erlang”


  1. [...] Java’s concurrency design is fundamentally different than other languages, such as Erlang, which has no notion of shared memory (consequently, there are no needs for locks, for example). [...]

  2. on 20 Oct 2008 at 8:04 am Chris EA

    It’s a shame you skipped the Mnesia chapter, it’s not just your everyday database. Just like the rest of the book, Mnesia introduces new ideas and paradigms.

  3. on 22 Oct 2008 at 6:35 pm history of cpus | Bookmarks URL

    [...] Book review: Programming Erlang It’s about speeding up your programs on multicore CPUs…it’s about designing methods and behaviors for writing fault-tolerant and distributed systems. It’s about modeling concurrency and mapping those models onto computer programs… … [...]


  4. [...] is an open source document oriented database written in Erlang that allows you to model domains in a flexible manner as a self-contained document that contains [...]


  5. [...] the task at hand a bit easier or at least safer to code (think situations involving threads (i.e. concurrency), for instance). And while I’ve thus far handled those situations with various libraries and [...]


  6. [...] a more functional paradigm that facilitates easier concurrency programming on the JVM. And while Erlang is an excellent platform for concurrency, it doesn’t run natively on the JVM; thus, the next [...]