Introducing Erlang

From Install to First Working App in 30 minutes

Introducing Erlang

The goal of this website is to get Erlang installed on your system and write a
non-trivial working application in 30 minutes. Through this we aim to show a
gentle introduction to a carefully chosen set of Erlang's features so you can
decide if Erlang is a good language for your needs.

Benefits of Erlang

Erlang makes hard concurrency and distributed system problems easier to
implement. Some of the great things Erlang offers include:

Installing Erlang

If you prefer to install Erlang from source, we recommend you use a tool like kerl which offers the same kind of isolation for Erlang environments that a tool like virtualenv brings to Python. Installation using kerl is straight forward:

Like my fourth grade English teacher, Erlang cares a lot about periods. A period is how the Erlang parser knows you've finished an expression. If you forget to put one on the end of an expression, the REPL will not return a value.

5> forgotten_period
5>

Notice that the REPL doesn't increment the command counter; that's a subtle clue its still on expression 5. To complete the expression, you can just enter a single period . and hit enter.

5> forgotten_period
5> .
forgotten_period

When you're tired of playing around with simple expressions, you can exit the REPL by executing the q(). function which tells the REPL to quit and terminate the Erlang VM.

Quick note on assignment

Erlang has immutable variables. Once a variable name is bound to a value,
Erlang will also "see" the bound value which can never be updated.

I know this sounds crazy to a programmer used to a traditional mutable
variable, but it turns out to be far less of a hassle than you might think in
practice.

Let's take a common Erlang data structure, a property list, as an example.

A property list is a list of tagged tuples in the form {Key, Value} where
the Key and the Value can be arbitrary Erlang terms (including another proplist).

Proplist = [{foo, 42}, {bar, true}, {qux, "Hello!"}].

Let's remove one of the elements from the proplist and assign it to a new variable.
One way to accomplish that is to use proplists:delete/2:

Your Second Application

We're going to build a to do list application. We will get some experience with the forms of Erlang programming including thinking about processes and message passing which are fundamental to understanding how Erlang applications should be designed.

The first thing we need to do is set up a directory structure. The Erlang standard is a directory tree like this