Skip to the content ForoHackers
Log inJoin

Erlang and Elixir: start here

Erlang and Elixir
#3083 · · Quote · 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

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply