Wednesday, 5 September 2007

Discovering Erlang/OTP

Since 1984 I'm now developing software, for myself, as a side job, as a part of my job and since 1999 as my main job. And during this time I've twice had the feeling that something very important reached the market. Both times I've been right, even if I've haven't been the first promoter. Now I've got this feeling again.

The first event has been 1989, when I discovered object-orientation for me. I've read about it before but in this year I've had the first chance to work with it. And I quickly realized that this is a very good paradigm to get a natural abstraction and encapsulation of data and behaviour. Until today I've developed most of my software this way. The second event has been 1996, when I wrote my first Java programs. Java as a language is inferior to pure and stringent object-oriented languages like Smalltalk. But in the late 90s Java had the right mix to gain ground. It has been pushed by Sun - only one company, no different ones with incompatible dialects, it could be used for free, the virtual machine supported the development on standard PCs and the usage on Solaris or Linux servers, the large runtime library provided a lot of functionality, and the curly bracket syntax attracted many C and C++ developers. This has been a very good package for the starting internet era.

And now, once again, I've got this feeling that a special technology fits optimal for upcoming challenges. Dual and quad cores in notebooks and desktop PCs, the new CPUs like the Sun UltraSPARC T2 processor and the Tilera TILE64 processor family, large data centers with a very high number of independent computers, or just the Internet show the direction. The computer technology is moving away from standalone high frequency single core systems to networked computers with a high number of cores. And future applications have to live in such environments, in some cases with a centralized infrastructure, in other cases loose coupled and communicating peer to peer. Those applications have to scale, work reliable, recover automaticly after high load or failure situations, and handle dynamic reconfigurations due to their nature running 24/7.

One possible solution for this challenge is an environment with a language that is not only supporting the development of parallel algorithms but is nearly enforcing it. A language, which focuses the usage of processes, which makes communication and distribution easy, and which prevents unreliable behaviour. Such a combination is Erlang/OTP. OTP is the acronym for Open Telecom Platform and shows the roots of Erlang, even if it is not restricted for telecom software.

Erlang is a strong and dynamic typed functional language, compiled to bytecode and executed in a portable virtual machine supporting hot code updates. It's available for Solaris, FreeBSD, Linux, OS X, VxWorks and Windows. Different processor architectures and SMP are supported. The notation is declarative with a powerful pattern matching like Prolog. In fact the development of Erlang has started in 1986 by Joe Amstrong with the experiment to add concurrent processes to Prolog. Those processes are now one of the major features of Erlang. They are extreme lightweighted, share no memory and communicate via asynchronous messages. Each node can handle a large number of processes and they can be distributed over the connected nodes. Processes can monitor other processes, even remote ones, restart them in case of an error or handle a fail-over and migration back for completely broken nodes. They are additionally independent of operating system processes or threads. The Erlang nodes are running VMs on the same machine or distributed over a network. The operating systems of these machines may differ. Started with the right parameter they build a virtual network where processes can communicate the same way independent of their location.

Beside the language, the compiler, and the VM Erlang/OTP contains a large and powerful library and helpful development tools. So e.g. a HTTP client and server, a FTP server, a distributed real-time database, a CORBA 2.0 ORB, and a SNMP agent are parts of the library. The tools contain monitoring, tracing, debugging, coverage, profiling, testing, and lots of stuff more. All have been proven in several high-available systems and applications, mostly telecom or internet. So today Erlang provides a powerful system focusing the development of reliable and scaleable software.

This focus is the main fact why I'm so fascinated. Many languages support threads and processes, support remote procedure calls, and support hot code deployment. And they all allow to develop reliable software. But I've never seen a language which enforces it like Erlang. So I've started my digging developing my first small evaluation project. You, too?

There is nothing more powerful than an idea whose time has come. (Victor Hugo)

0 Comments: