Platinum Partner
java,languages

Day 5 - Erlang

If you are just dropping in on me, I'm reviewing Bruce Tate's Seven Languages in Seven Weeks, with the slightly lazy (or aggressive, depending on your view) twist of reviewing one language per day. As you can imagine, shrinking an already-tight one-week study schedule to one day means glossing over some things and skipping the extra exercises. The idea, though, is to still get a good feel for the topography of the language, and as I've already pointed out, this is a great little book and will be my first contact for the languages I choose to get to know a little better.

The 5th language of this book is Erlang ("Ericsson Language"), first developed by Joe Armstrong in 1986. A functional, dynamically-typed language geared toward telecommunications and its high availability requirements, Erlang relies on lightweight processes (rather than threads) as its base model. It is based on and quite similar to Prolog, something brought out by Bruce's interview with Joe Armstrong. Have I said I really like the interview portions of this book? After enough years in this industry, I had started to say "one more language; let me take a look at it and just give me the API docs", but after reviewing these languages I see I've overlooked the huge amount of variety in the development-language world.

Erlang is a compiled language, but it provides an interpreter which Bruce uses for the earliest, shortest examples. In his Day 1, Bruce discusses atoms, variables, lists and tuples, and gives a short discussion of pattern matching (including bit matching). Day 2 starts by discussing control structures, mostly case statements but also including the if statement.

Bruce then moves on to higher-order functions, starting with anonymous functions, and discusses using functions to manage lists. Highlights include the foldl and foldr functions, as well as a brief review of Erlang's list comprehension.

On Day 3 (using Bruce's timeline), he talks about concurrency. I said earlier that Erlang looked more to lightweight process than lightweight threads as a base model. The concurrency primitives in Erlang are sending messages, spawning processes, and receiving messages. He covers pattern matching in receive loops, which have a syntax similar to case statements, then discusses the use of spawn to spawn a process. Finally, the returned process ID of the spawned process is used as the destination for messages. He walks us through an asynchronous example, followed by a simple asynchronous messaging example. He then discusses linking processes and how to handle death (exit) of a process by its linked process (a technique used to create monitoring and keep-alive services).

The end of the Erlang section covers strengths and weaknesses of the language. One weakness, if you can call it that (at least from an adoption point of view) is not being on the Java Virtual Machine. I thought of this frequently while going through the Erlang section of this book. Reading about Erlang's support for concurrency is refreshing and quite inspiring for me. However, I know that I will most likely eventually use Scala. Why? That JVM is just going to make it a lot easier to sell to management. That might be a shame, but it's kind of a fact of life. I remember really liking Smalltalk, but realizing that summer was coming to an end and going with C++ anyway. But it doesn't mean I don't still think fondly of my first Smalltalk application. :) 

From http://wayne-adams.blogspot.com/2011/04/day-5-erlang.html

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}