Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
executable file 145 lines (122 sloc) 4 KB
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<title>Getting Started</title>
<prepared>Matthias Lang</prepared>
<section><title>How long does it take to learn Erlang?</title>
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.
<section><title>How can I learn Erlang?</title>
There's an <url href="">
online tutorial</url>. Any of the
<seealso marker="obtaining#books"> Erlang books</seealso> can
also be used as tutorials.
The Erlang distribution includes a step-by-step <em>getting
started</em> guide. This is also <url
<url href="">
Ericsson</url> run training courses for Ericsson employees.
<url href="">
</url> and <url
both run training courses (primarily in London and Stockholm,
but also in the US, Asia and Australia) aimed at
Many <seealso marker="introduction#universities">universities
</seealso> 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.
<section><title>What does "hello world" look like?</title>
Here's one way to write hello world:
hello_world() -> io:fwrite("hello, world\\n").
To compile this, save it in a file called <c>hello.erl</c> 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
<section><title>How do I quit the Erlang shell?</title>
To shut a system down cleanly, use <c>init:stop().</c>
Some quick ways are evaluating <c>halt().</c> or
<c>Control+C</c> and <c>Control+G</c>
give you access to menus.
<section><title>Why does Erlang print "ok" after my program's output?</title>
The Erlang shell works by <em>r</em>eading an
Erlang expression,
<em>e</em>valuating it,
<em>p</em>rinting the result and
for another expression, i.e. a REPL shell.
The <c>io:fwrite()</c> function does two things.
It prints out "hello world" and it returns the value
So, when you execute <c>io:fwrite("hello, world\n")
</c> in the shell, the <c>fwrite</c>
function prints the first line and the shell prints the return
value, <c>ok</c>. This can be
avoided by <seealso marker="how_do_i#noshell"> running
Erlang without a shell</seealso>.
Jump to Line
Something went wrong with that request. Please try again.