Tuesday, March 15, 2011

Intro to Erlang


Overview of Erlang:

From wikipedia[15 Mar 2011]:
Erlang is a general-purpose concurrent, garbage-collected programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing. For concurrency it follows the Actor model. It was designed by Ericsson to support distributed, fault-tolerant, soft-real-time, non-stop applications. It supports hot swapping, thus code can be changed without stopping a system.

Its concurrency and hot-code swapping were excellent for telecom uses, and reportedly tested to a nine nines reliability rating. The message passing paradigm is excellent for use with multi-processor systems that are growing in popularity. Currently, the 3 most prominent Erlang projects are ejabberd the XMPP instant messaging server that Facebook chat is based on, Apache's CouchDB, and Claes Wikström's YAWS (Yet Another Web Server). In a 2002 comparison YAWS was tested to handle 80,000+ simultaneous connections beating the next closest contender Apache2 which failed at around 4,000.

And here's an amusingly odd(oddly amusing?[neither?]) video demonstrating the benefits of Erlang:



On with the code:


You'll need a functioning Erlang shell, I recommend a *nix(subjective perhaps but I tried it in XP and on Ubuntu's CLI and Ubuntu felt more natural) . If you're on a *nix, type:
$ erl

If the response isn't similar to:
Erlang R13B (erts-5.7.1) [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] 
Eshell V5.7.1 (abort with ^G)

1>
or you're using Windows go to: http://www.erlang.org/download.html

Robert Baruch's - Thinking in Erlang is an excellent, quick, and free introduction for those with programming experience. I offer one point of clarification to his concise doc: source code is not directly written in the shell. Code is written in a text editor, saved to a directory, and then run from the shell. More info: http://www.erlang.org/quick_start.html

Conclusion:


Having completed Baruch's introduction, you are more knowledgeable about a promising, new-ish programming language. To learn more:

http://www.erlang.org/starting.html
http://www.erlang.org/links.html

Yariv's blog
Erlang creator Joe Armstrong's book

1 comment:

  1. That was a cute demo!

    The ability to swap modules in and out while not interfering with the rest of the running system was very nice.

    When I worked with OS-9, I used to load/unload modules all the time, while not rebooting the system.
    http://en.wikipedia.org/wiki/OS-9

    ReplyDelete