Erlang programming techniques

=Erlang Programming Techniques=

Erlang was created with the aim of "Making reliable distributed systems in the presence of software errors" as the title of Joe Armstrong's dissertation states.

The creators of Erlang has tried to solve that using a particular philosophy which makes certain programming techniques more powerful than others. This article will present the philosophy and the most powerful programming techniques.

Why this article?
This article is to a large extend a mash-up of Chapter 4 of Joe Armstrong's dissertation plus a definition of some of the key functionalities of Erlang so that the content can be easily understood by people that do not know anything about Erlang.

The intention is to provide non-Erlangers to get an idea of how Erlang affects the creation of software and what benefits that might bring about.

=Fundamental Features of Erlang=

Processes, Processes, Processes
Erlang provides its own processes without resorting to the underlying OS. This is done so efficiently that several millions of processes can run on the same machine. It is not just an academic show-off - the intention is to create as many processes as required to capture the truly concurrent activities of the system being created.

Pure message passing
The only way for for processes to communicate is to send messages to each other. There is no no shared state between processes which removes many of headaches normally associated with concurrent programming (todo: find reference).

Strong isolation between concurrent processes
The failure of one process will not cause other processes to fail.

Since failures are unavoidable in software Erlang has mechanisms that allows a process to detect if another process has failed and why it has failed, but the ability to detect the failure of another process does not make the process itself fail.

A failure in one process can cause other processes to fail, if and only if that behaviour is explicitly programmed.

=Abstracting Out Concurrency=

="Maintaining the Erlang view of the world"=

todo: find a better title for this.

=Error Handling Philosophy=

This is where Erlang has taken a radically different approach than most other technologies, but it is also this approach that greatly simplifies the work of the programmer as we shall see.

Let some other process do the error handling
No matter how much one tries to handle all possible errors in a piece of code chances are that there are still errors in the code and when one of those occur the code will fail.

Erlang is designed to utilise remote handling of errors, which gives the following benefits compared to the more traditional programming languages:


 * 1) The failing code and the error-handling code runs in different threads of control
 * 2) The code which deals with the error is not wowen into the code that solves the real problem.

Erlang uses the terms workers and supervisors for this...

=Fail-fast=

=Intentional Programming=