Erlang

April, 2010

So I must confess this Monday morning to having spent the weekend very much infatuated with Erlang. I do not know how long this phase will last, but we might as well talk about it while its fresh. I’ve always had an interest in building distributed systems and writing software with concurrency. Some of my first explorations in these areas happened while working on the robots and laser where I built multi-threaded, multi-process and multi-node software systems to control a variety of robotic equipment while taking input from various sensor and human sources. I did this at a very low level: connecting DSPs running assembly and C to motor controllers and dedicated feedback loop processors to ‘high level’ general purpose CPUs running hard RTOSes with C++ as my language of choice. I learning about IPC and multi-threaded designed, wrote my own low level protocols and did a lot of bit shifting and binary arithmetic. Even in the applications I build today in C#, I’m always exploring the different aspects of concurrency and distributed processing. Snap sync is architected from the ground up to scale across multiple nodes and has a unique asynchronous processing model where the number of sync workers is not equal to the number of threads. Even after all this experience I still feel like writing multi-threaded, multi-processes, scalable code is very hard. There is so much that can go wrong and so much work to do in object orient languages to make sure you are using the proper locks and sync objects.

Erlang, however is specifically designed to be used for creating concurrent distributed systems with high availability. The capabilities to do this are built directly into the language constructs itself . It has been very exciting to approach the language from the perspective of having spent a lot of time building custom distributed, concurrent systems of my own. The simplicity and beauty of Erlang code to solve these problems is quite amazing. Now before I gush on let me say that Erlang is a tool for a very specific problem. There are many different programming tasks that i would not choose Erlang for like creating a rich client UI or to do front end web development. In the same vien, starting to learn Erlang has made me wonder about the places I’ve been using the wrong tool for the job.

I’ve really only just begun to learn the language. I’ve been walking through some tutorials, built a few small programs, etc. I went ahead a bought Joe Armstrong’s book and screen casts from the pragmatic programmer and would highly recommended them to anyone interested. You can download Erlang here. This is a very interesting article showing how a web server written in Erlang (Yaws) compares to Apache in handling concurrent requests. The net net of the metrics is that Apache (running on a single server) dies at about 4,000 concurrent sessions. Yaws on the other hand (same server) is still kicking at 80,000 concurrent sessions. Impressive.

Maybe snap sync could use a little Erlang love? …

Tim's Avatar Building GitHub since 2011, programming language connoisseur, San Francisco resident, aspiring surfer, father of two, life partner to @ktkates—all words by me, Tim Clem.