Erlang - a very different and promising platform

An artificial language with an 'E' - no,  not esperanto - : Erlang. Erlang has an aura of being new and exciting, despite it has initially been developed back in the nineties by the telecommunications company Ericsson. Erlang in fact is quite simply 'Ericsson language'. 

What makes it so special? A number of things: the platform, the language, strong academic influences and may be also the fact that it is from Scandanivia, more precisely from Sweden. A short introduction, choosen from a Java point of view.

Erlang runs on a virtual machine. Just like Java source code is it being compiled. But then there is a huge difference. The Java virtual machine is mapped to the machine it runs on. It lives and will die on this particular machine. On the contrary, Erlang has a promise of immense scalability. All you have to do is make virtual machines aware of each other - as different nodes - and an application will scale over a network. To the server next to it, or to a machine on the other side of the world. Does a machine, fail, the others will continue.

The platform of Erlang has been designed with scalability, large number of clients - think thousands, or even millions - , fault tolerance, real time response and non stop availaibility in mind.  These are the kind of business issues that appeared early in the telecommunciations industry but become nowadays increasingly important in other sectors and for other applications as well. This is a paradigm shift: don't think 'servers' anymore but think in 'clusters' consisting of a number of nodes. 

There is another abstraction from the physical hardware that matters. A program in Java runs one or more processes on threads that belong to the underlying operating system and hardware.
An Erlang process only exists on the level of the Erlang virtual machine. There can be hundreds of processes. You can also delegate some to other nodes in the network. The Erlang virtual machine takes care of the mapping of processes to the underlying operating system and hardware.
In Java whether or not to start a new thread is a decision. Erlang's processes are very lightweight which means you start new ones without fearing too much performance penalties.
Because of that you start as many as are possible within the application logic, and the more CPU-cores become available, the faster your application will get. Now, and over five years.  

But, to make that possible the designers of Erlang took a decision that will take you some time to get used to. It boils down to one simple statement: no state. Erlang processes live without state. Think of it as a Java class with the methods but without the properties. So we have an object called Smith belonging to the class person but we cannot set the color of his eyes. 
There are more things to get used to. You cannot write x=x+1. Every variable can only be bound once. Period. In fact, any expression is strictly like in math class: x=x+1 would be invalid there too. y=x+1 is ok.
The advantage lies primarily in the virtual machine and its memory allocation. The obligation to end every line with a dot is just minor in comparison. 
It is a functional language.  A lot of what you write is about matching patterns, executing functions and passing functions as arguments to lists and to other functions.
To know what this means and how to do it is the first step. The second, more important step is to do it in an useful, beautiful, maintainable way. 

What else do we need? Of course, the usual: a web server, an application server and a database. A database called Mnesia is built in.  Web server and application server functionality come as one application. All run on the Erlang virtual machine.
You get acces to your database not over a performance expensive bridge (jdbc, socket, port) but within the virtual machine itself. Mnesia is designed to primarily use in memory storage with the possibility of on disk storage, eventually by replication. Of course, Mnesia thinks also in clusters and nodes over the network.
The data types in your application and in your database, they are identical. Because it is just Erlang virtual machine space. The same kind of benefits apply to the web/ application server. It is all integrated and at the same time distributed over the network. 

Finally, this is a platform and a language with a very specific background. It has been around for a long time. Without any apparent commercial pressure to a certain growth percentage, a focus on the next quarter or the need that it should look to be easy to use. It reminds that way of MySQL, also originating from Sweden. Where they made the money by selling the printed manuals. Can you say something of the cultural background related to software development? I guess it is unexplored terrain. But for me, now, the fundamental approach of Erlang fits a country with just seven million people that is capable to design its own fighter jets and as some guy from Sweden once told me: in most places of the world they spend money to do things half seven times over and over again, we try to do things right. 

Is this an environment that will suit your company? Does it fit your business? I would be glad to help you to find just that out. 

Overname alleen na voorafgaande toestemming.