Hero roadmap: the whole course on one page
The path in five blocks
This last lesson has no code. It is the map of the course: five blocks of ten lessons, what each block gives you, and where to go next. Every lesson title below is a link back to its page, so the page doubles as an index.
Lessons 1 to 10 build the language: what Erlang is and where it runs, installing Erlang and checking the version, the erl shell, your first script, variables and single assignment, numbers, atoms, strings and binaries, truthiness and case and if. At the end of the block you can write a small function, run it, and explain why a variable never changes.
Lessons 11 to 20 build the data model: recursion instead of loops, lists, tuples, maps, functions and clauses, pattern matching, guards, records, exceptions and modules, exports and imports. This is the block that makes Erlang feel different from a language with objects: the data has a shape, and the code matches on it.
Lessons 21 to 30 build the toolchain: funs, higher-order functions, keyword lists, idioms and clean code, rebar3 builds, EUnit, debugging, encodings and Unicode, time and date and JSON and term formats. After it you can start a project, write a test, find a bug, and talk to the outside world in a format other languages read.
Lessons 31 to 40 build the runtime: processes and message passing, spawn and links, monitors and exits, GenServer, supervisors, OTP applications, files, sockets, HTTP clients and io:format and output. This is the OTP block, and it is the reason the language is used at all: a tree of processes that restarts itself.
Lessons 41 to 50 build the system: let it crash, ETS, timers and timeouts, code loading, distribution, the two capstones (a todo CLI and a chat server), performance and the modern toolchain, and this map. By the end you have written a supervised application, a command line tool, a network server with several clients, and a type checked module.
What to build next
Three projects take the course further, in the order that teaches the most. First, turn the chat server of lesson 47 into a supervised application: the acceptor becomes a GenServer, a supervisor owns it, and the application of lesson 36 starts the tree. You will hit every OTP question at once, and none of them is new.
Second, add persistence. Put the todo list into ETS and the ETS table into a GenServer that owns it, so a restart loses the state: then decide what to do about that, with a file on every write or a periodic dump. The choice is the lesson, not the code.
Third, make two nodes work together. Start the same release on two nodes, move the GenServer to one of them, and call it from the other with rpc. When the first node dies on purpose, the monitor of lesson 33 and the supervisor of lesson 35 should tell you exactly what happened.
The BEAM family
The Elixir language runs on the same virtual machine as this course. If the fault tolerance and the concurrency are what you liked, Elixir keeps both and adds a friendlier syntax, protocols and a build tool of its own. Start the Elixir course here: /dev/elixir/.
Ruby takes the other road: objects, blocks and a culture of programmer happiness. Many Ruby teams run their code on the JVM or on the BEAM through ports and NIFs, and knowing what happens on the other side of that boundary is worth a lot. The Ruby course starts here: /dev/ruby/.
For the wider picture, the theory section explains the actor model behind all of this: /dev/theory/. And the course index, with every lesson in order, is /dev/erlang/course/.
This is the last lesson of the course. Go back to the start: /dev/erlang/course/
Questions
A new set of questions in a new order every time. Choose one answer for each, then check.
-
What does single assignment mean in Erlang?
Answer
A variable can be set once and never rebound
A bound variable keeps its value; a second match either agrees with it or fails.
-
Why does Erlang use recursion where other languages use loops?
Answer
Variables never change, so a loop counter cannot be updated in place
Without mutable variables, repetition is a function called with a new argument.
-
What is a guard for?
Answer
To test a clause beyond the pattern match
A guard such as
when N > 0filters the clauses the pattern alone would accept. -
What does a supervisor do?
Answer
Starts children and restarts them by a strategy
The supervisor keeps the tree alive according to the child specs and the restart strategy.
-
What is the difference between a link and a monitor?
Answer
A link is bidirectional and kills, a monitor only reports
Links propagate exits both ways; a monitor sends one DOWN message and nothing else.
-
When is an ETS table the right place for state?
Answer
For data several processes read and write
ETS is shared memory inside the VM, so it fits shared state and hot lookups.
-
What does let it crash mean?
Answer
Let a process die and restart it from a supervisor
A clean crash and a fresh restart beat a process that keeps running with broken state.
-
Which call runs a function on another node?
Answer
rpc:call/4rpc:call(Node, Module, Function, Args)runs the function there and returns its value. -
What does Dialyzer check?
Answer
The types of the calls and the returned values
It reads the beams and the specs and reports calls that can never work, without false positives.
-
Which pair of tools does a modern Erlang project use for build and tests?
Answer
rebar3and EUnit or Common Testrebar3 builds, releases and runs the tests, with EUnit or Common Test as the test framework.
Article author: Arthur Isaev