Introduction
Most languages crash when something goes wrong; a failed process takes down the request, or the server. Elixir, released in 2011 and built on the Erlang virtual machine (BEAM), was designed by telecom engineers who could not afford crashes: phone switches must run for years without stopping. Its answer is "let it crash" — isolate failures in tiny processes, supervise them, and restart only what failed. That philosophy now powers chat systems, real-time apps, and the Phoenix web framework, and it changes how you think about reliability.
Processes, messages, and supervision
Elixir's model is built on the actor model:
- Processes — extremely lightweight (thousands per megabyte), isolated units of execution that communicate only by sending messages, never by sharing memory. A process crash affects nothing else.
- Supervision trees — supervisors watch worker processes and restart them on failure, with strategies: restart one, restart all, or restart in order. Failures become routine events, not emergencies.
- Let it crash — instead of defensive code everywhere, write the happy path and let supervisors handle the rest. The system heals itself.
- Hot code upgrades — the BEAM can replace running code without stopping the system, the feature that kept phone switches running for decades.
A tiny example shows the shape — spawn a process, send it a message, receive a reply:
pid = spawn(fn ->
receive do
{:hello, from} -> send(from, :world)
end
end)
send(pid, {:hello, self()})
receive do
:world -> IO.puts("Got world!")
end
No shared state, no locks, no crash propagation — just messages between isolated processes, supervised from above.
The honest trade
Elixir's trade is ecosystem and hiring: a smaller community and job market than Python or JavaScript, and a functional style that takes adjustment for imperative programmers. Raw CPU-heavy computation is not its strength either (the BEAM optimises for concurrency, not number crunching). The rule of thumb: Elixir when fault tolerance, concurrency, and real-time features matter most; a mainstream language when ecosystem depth or raw compute dominates.
Takeaway
Elixir is fault-tolerant code that never stops: lightweight processes, message passing, and supervision trees that restart what fails. It trades mainstream ecosystem for reliability designed in from the start — and for systems that must not stop, that trade is everything.
Originally published at https://practicaldevblog.blogspot.com/2026/10/elixir-explained-fault-tolerant-code.html
Top comments (0)