Erlang logo

Getting Started


Expand All
Contract All

Table of Contents

4 Getting Started

4.1  How long does it take to learn Erlang?

It depends. (did you expect anything else?)

With an imperative language background (e.g. C, Python, Java, C++, Pascal, PERL, etc.), it takes most people about a week before they can write nontrivial programs, about a month to feel really comfortable and a few months before feeling ready to take on something big by themselves. It helps a lot to have someone who knows how to use Erlang around for some hand-holding.

With a background which includes another declarative language (Lisp, Prolog, Haskell, Scheme, etc.), you'll be able to hack Erlang code straight away, though learning to take advantage of the fault tolerance and concurrency takes a while.

4.2  How can I learn Erlang?

Many people learn on their own, using a book or an online tutorial, often in conjunction with posting to the erlang-questions mailing list or #erlang IRC channel on

Learn You Some Erlang is an easy-going tutorial which takes a day or two to get through. Alternatively, there's a spartan online tutorial.

Any of the Erlang books can also be used as tutorials.

The Erlang distribution includes a step-by-step getting started guide. This is also online.

Ericsson run training courses for Ericsson employees. run training courses (primarily in London and Stockholm, but also in the US, Asia and Australia) aimed at businesses. These are often in conjunction with the yearly Erlang User Conference.

Many universities run courses either partly or wholly about Erlang. Courses about functional programming are also useful for getting a solid grounding which will then let you easily learn Erlang by yourself.

4.3  What does "hello world" look like?

Here's one way to write hello world:


	hello_world() -> io:fwrite("hello, world\n").

To compile this, save it in a file called hello.erl and compile it from the erlang shell. Don't forget the full-stop ("period" in American English) at the end of each command, as shown:

	Erlang (BEAM) emulator version 4.9.1 [source]

	Eshell V4.9.1  (abort with ^G)
	1> c(hello).

(on unix systems you start the erlang shell by typing "erl" at the command line. On Windows, open a command prompt window and type "werl", or find the Erlang icon in the programs menu). To run the program from the Erlang shell:

	2> hello:hello_world().
	hello, world

4.4  How do I quit the Erlang shell?

To shut a system down cleanly, use init:stop().

Some quick ways are evaluating halt(). or Control+\.

Control+C and Control+G give you access to menus.

4.5  Why does Erlang print "ok" after my program's output?

The Erlang shell works by reading an Erlang expression, evaluating it, printing the result and looping for another expression, i.e. a REPL shell.

The io:fwrite() function does two things. It prints out "hello world" and it returns the value ok.

So, when you execute io:fwrite("hello, world\n") in the shell, the fwrite function prints the first line and the shell prints the return value, ok. This can be avoided by running Erlang without a shell.