Regular readers will know that I find most so-called "modern" programming languages to be somewhat underwhelming. Occasionally, though, one comes along that provides a nice contrast. One of these is Erlang.
Erlang was originally designed by Ericsson for high-availability, high-performance applications, such as telephone switchboards. Since Ericsson’s market is telecommunications, not programming languages, they released it as Free Software, including an extensive runtime library. Improvements have been made by others, including the University of Uppsala, which contributed most of the High-Performance Erlang (HiPE) branch.
Being commercially supported Free Software is a good start. The fact that Erlang has already been used in real-world projects of significant scale is another point in its favor. This article is not intended as an in-depth tutorial on Erlang, but rather as a taste of what’s possible with the language.
’Scalable’ Is the New ’Fast’
It used to be that if your code ran quite quickly, a year later you could run it twice as fast for the same amount of money. These days, you’re much less likely to get a chip that’s twice as fast, but you may get one with twice as many cores. If your code is highly parallel, you can just spread it out a bit more.
To provide some context, the machine I was using as my testbed for the last project I wrote in Erlang was a 64-processor MIPS box, already several years old. A pair of Sun T1 chips can have as many active contexts as this machine, and eight of them can have as many actually executing as this old machine—and doing it faster. Within a few years, it seems likely that laptops will emerge with similar abilities to this old behemoth.
Two features of Erlang, both of which are built into the language, make it especially suited to writing scalable applications: process creation and message passing.
Erlang is interpreted on all platforms, but can be just-in-time compiled on x86 and SPARC. In the worst case, algorithms implemented in Erlang run at about one-tenth the speed of their C counterparts. Distributed algorithms can run faster. Yet Another Web Server (YAWS), written in Erlang, has been shown to be able to handle more concurrent connections than Apache on the same machine, and the ejabberd XMPP server is very well-regarded in the community.