Skip to content
Tutorials Center
My learning

Topics

Erlang Tutorial

Learn Erlang step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Erlang? Meet Erlang: a functional language built at Ericsson for telephone switches, with lightweight processes, fault tolerance and the BEAM virtual machine.
  2. 2 Installing Erlang and Using the Shell Install Erlang/OTP on Windows, macOS or Linux, start the erl shell, evaluate expressions, use history, and learn the shell commands you will use every day.
  3. 3 Your First Module: Writing and Compiling Write your first Erlang module, export functions, compile it with erlc or c/1, run it from the shell and understand attributes, arity and export rules.
  4. 4 Projects with rebar3 Use rebar3, the standard Erlang build tool: create an application, understand the project layout, compile, run the shell, add dependencies and build releases.

Language Basics

  1. 5 Numbers and Atoms Learn Erlang's basic data types: arbitrary-size integers, floats, number bases, atoms, booleans and the type-checking functions every beginner needs.
  2. 6 Variables and Single Assignment Understand why Erlang variables bind only once, how the = sign is a pattern match rather than assignment, and how to use underscore and scope safely.
  3. 7 Operators, Comparison and Booleans Learn Erlang's comparison, boolean and bitwise operators, the difference between == and =:=, short-circuit andalso/orelse, and how terms are ordered.
  4. 8 Printing Output and Working with Strings Print with io:format and its control sequences, understand why Erlang strings are lists of integers, and use the string module, binaries and iolists.

Functions and Pattern Matching

  1. 9 Functions and Clauses Learn how Erlang functions work: clauses and heads, arity, the last expression as return value, multiple clauses, private helpers and function references.
  2. 10 Pattern Matching in Erlang Master Erlang pattern matching: match tuples, lists, maps and strings in function heads, case and receive, bind variables and use the common ok/error idiom.
  3. 11 case, if and Guards Choose between branches in Erlang with case, if and guard sequences. Learn which functions are allowed in guards, how guards fail safely and when to use each form.
  4. 12 Recursion and Tail Calls Replace loops with recursion in Erlang: base cases, list recursion, accumulators, tail-call optimization, and why tail recursion keeps long-running servers alive.
  5. 13 Funs and Higher-Order Functions Use anonymous functions (funs) in Erlang, capture variables in closures, pass funs to lists:map, filter and foldl, return funs and write named funs.

Data Structures

  1. 14 Lists in Erlang Work with Erlang lists: linked-list structure, head and tail, cons, append, the lists module, sorting, searching, zipping, proper lists and performance traps.
  2. 15 List Comprehensions Build lists concisely with Erlang list comprehensions: generators, filters, multiple generators, pattern generators, binary comprehensions and map comprehensions.
  3. 16 Tuples and Records Use Erlang tuples for fixed-size groups, tagged tuples for results, and records for named fields with defaults, updates, pattern matching and header files.
  4. 17 Maps Use Erlang maps as key-value data: create, read, update with => and :=, pattern match, iterate, use the maps module and choose between maps, records and proplists.
  5. 18 Binaries and Bit Syntax Build and parse binary data in Erlang with bit syntax: segments, sizes, types, endianness, pattern matching network packets, bitstrings and binary functions.

Processes and Message Passing

  1. 19 Processes and spawn Learn how Erlang processes work: spawn, self, process identifiers, isolation, cheap creation, and why millions of processes can run on one machine.
  2. 20 Sending and receiving messages Learn Erlang message passing: the ! operator, mailboxes, receive with pattern matching, replying with the sender's pid, and request-response patterns.
  3. 21 Selective receive and timeouts Learn how Erlang receive picks messages out of order, how the after clause adds timeouts, how make_ref prevents mixups, and how to avoid mailbox scans.
  4. 22 Process loops and state Learn how Erlang processes keep state without variables that change: tail-recursive receive loops, counters, servers, hot code loading, and clean shutdown.
  5. 23 Registered processes and the process dictionary Give Erlang processes names with register/2 and whereis/1, send to names, learn the limits of the name registry, and why the process dictionary is best avoided.

Fault Tolerance and OTP

  1. 24 Links, monitors and exit signals Understand how Erlang processes detect each other's failure: spawn_link, exit signals, trap_exit, monitors and DOWN messages, and the let it crash philosophy.
  2. 25 gen_server: the OTP generic server Learn the OTP gen_server behaviour: init, handle_call, handle_cast, handle_info, terminate, start_link, timeouts and a complete key-value server example.
  3. 26 Supervisors and supervision trees Learn OTP supervisors: child specs, one_for_one, one_for_all and rest_for_one strategies, restart intensity, temporary and transient children, and supervision trees.
  4. 27 OTP applications and releases Package Erlang code as an OTP application: the .app resource file, the application behaviour callback, environment variables, dependencies, and building releases.

Distribution and Ports

  1. 28 Distributed Erlang: nodes and clusters Connect Erlang nodes into a cluster: node names, magic cookies, net_adm:ping, sending to remote pids, rpc calls, global names, monitor_node and security.
  2. 29 Ports, NIFs and TCP sockets Talk to the outside world from Erlang: open_port for external programs, NIFs and port drivers, gen_tcp servers and clients, active and passive sockets.

Tools and Testing

  1. 30 rebar3: building Erlang projects Use rebar3, the standard Erlang build tool: create apps and releases, rebar.config, dependencies from Hex, profiles, compile, shell, eunit, dialyzer and releases.
  2. 31 Testing Erlang: EUnit, Common Test and PropEr Write Erlang tests with EUnit assertions and fixtures, run integration suites with Common Test, and find edge cases with property-based testing using PropEr.
  3. 32 Debugging, tracing and the Observer Inspect running Erlang systems: io:format and logger, process_info, the Observer GUI, dbg tracing, the recon library, crash dumps and finding a mailbox leak.
  4. 33 Types, specs and Dialyzer Document Erlang functions with -spec and -type, define custom and opaque types, run Dialyzer to find discrepancies, and understand success typing.

Projects and Practice

  1. 34 Project: a chat room with processes Build a chat room in Erlang from processes and messages: a room server, join and leave, broadcast, monitoring clients, and a runnable JavaScript model of the design.
  2. 35 Project: a supervised key-value store Build a key-value store as a real OTP application: a gen_server with TTL expiry, ETS-backed reads, a supervisor, tests and a runnable JavaScript model.
  3. 36 Practice: concurrency and OTP exercises Twelve graded Erlang exercises on processes, message passing, receive timeouts, links, gen_server and supervisors, with hints, solutions and a runnable model.