The Soul of Erlang and Elixir by Saša Jurić

This video was on the front page of HN today. It might only interest people who are already curious about Elixir/Erlang, but it shows some of the features. His book Elixir in Action is good.

Here’s a 3-minute video that shows one of Elixir’s interesting features, comparing it with Node.js and Python. It references the talk above.

Also related: Concurrency vs Parallelism and the Erlang Advantage

The Erlang Advantage

The Erlang VM (known as “The BEAM”), on which all Erlang and Elixir code runs, is sometimes called an operating system for your code. Like a system OS, it allows for parallel execution and uses preemptive multitasking. This is in contrast to, for example, Node.js, which is single-threaded and uses cooperative multitasking. Node.js juggles IO tasks efficiently, but a single slow computation could bring all its work to a halt.

The BEAM loses a bit of raw speed by switching tasks so much, but the payoff is that it performs more consistently. For example, suppose you have a Phoenix application where people upload data for processing, and you respond with the processed data. Or suppose you have to parse large XML API responses in order to respond.

Because Phoenix is fronted by Cowboy, every incoming request gets its own BEAM process. If most requests are small, but you occasionally get an expensive request, it’s no problem; the other incoming requests won’t be affected at all, because the heavy process will keep getting paused to give the other ones a turn. That’s true whether the “heavy” process is waiting on IO or performing a long computation.

And if you have multiple cores, the BEAM will use them all to get work done in parallel. The more cores you have, the more this outweighs raw speed.