Skip to the content ForoHackers
Log inJoin

Erlang and Elixir: start here

Erlang and Elixir
#577 · Ophuscado · · Report

Erlang and Elixir run on the same virtual machine, built for systems that must stay up: telecom switches, messaging servers, chat and web back ends. Programs are many tiny isolated processes that talk by messages, and that are expected to fail and be restarted. Elixir adds modern syntax, macros and tooling on top of the same foundation.

Key concepts

  • Processes: very cheap, isolated tasks with their own memory and no shared state.
  • Message passing: processes communicate by sending messages to mailboxes.
  • Let it crash: instead of defensive code, let a failing process die and have a supervisor restart it.
  • Supervision trees: processes organised so that failures are contained and recovered.
  • Pattern matching and immutability: data never changes, and function clauses select on shape.
  • OTP: the standard libraries and design patterns for servers, state machines and applications.

Vocabulary

  • BEAM: the virtual machine that runs Erlang and Elixir.
  • GenServer: a standard process that holds state and answers requests.
  • Supervisor: a process whose job is to start and restart others.
  • Hot code upgrade: replacing code in a running system without stopping it.

What to study, in order

  1. Basic data types, pattern matching, recursion and the interactive shell in your choice of language.
  2. Spawn processes, send and receive messages, and build a simple counter process.
  3. Write a GenServer and a supervisor that restarts it when it crashes.
  4. Build a small chat or key-value server with several clients.
  5. Monitors, links and what happens when processes fail.
  6. Distribute across two nodes and observe the system while it runs.

Related tags

#concurrency #functional-programming #distributed-systems #messaging

Log in or join to reply.