Basic steps

Why Erlang, what is erlang, etc? Erlang is a programming language developed by Ericsson to provide a language that is functional to maximise efficiency (code reuse, higher order functions, see "Why is functional programming useful?") while at the same time allowing concurrency and distributed processing (vital in telecoms applications). Processes in Erlang are lightweight ie it takes little computational resources to create a new process and so programs can be thought of as consisting of a set of interacting "machines" that talk to each other by passing messages.

Start learning how to program in Erlang:

"Getting started with Erlang"

Basic types in erlang:

Modules are the basic compilation unit in erlang, ie define a module in a file module_name.erl by giving the module name and the functions the module exports, then define the functions. Functions that are not exported are private to the module.

Pattern matching can be used in function definitions eg a factorial module tut1:

%%% Code: tute1.erl


fac(1) -> 
fac(N) ->

%%% End Code: tute1.erl

Use this file in the interactive shell erl using "c(tut1)." to compile the file, then eg "tut1:fac(50)." to use the function

Points to note about erlang modules:

Processes in Erlang

One of the main driving forces behind erlang is its use in distributed environments. To facilitate this process creation is easy in terms of the computational resources required. Processes are distinct from threads in that threads can share data between themselves while processes have distinct local data. New processes are created using the built-in-function (BIF) spawn taking three arguments, the module name to spawn, the function within the module that is called when the module is spawned, and the list of arguments of the module.

The syntax for passing messages between processes is PID ! Message, where Message is any erlang term. If you want the receiving process to talk back to the sending process it is a good idea to send the PID of the sender along with any other data. Alternatively, the processes can be registered using register(some_atom, PID) so that the atom can be used as a process identifier rather than the PID itself.