What is elixir? An introduction

Elixir is a functional, concurrent programming language used to build distributed, fault-tolerant applications.

Every time we see somebody talking about elixir we see these keywords, hopefully by the end of this post you will understand why. In this post I’m going to explain how Erlang came to be, and how elixir builds on top of that.

Before learning about elixir let’s talk about Erlang, the language elixir is based on:

Erlang is a language designed by Ericsson in the 1980’s with the goal to build a telecommunication network.

Elixir code compiles to the Erlang Virtual Machine bytecode, these machine was originally built for the Erlang programming language. Because they compile into the same code, they share the same core functionality.

Here’s an (old) video explaining the use case Erlang was originally built for, machine switches:


Erlang was build to make systems for a rather constrained environment. Some of the constraints at the time were:

Fault tolerant: The system has to be available 24/7, 99.99% of the time. We use supervisors to restart processes immediately, the system had to be highly available with virtually no down time.

Concurrency: The computers had very low amounts of memory, so processes had to be light weight and isolated from each other(terminating a connection shouldn’t kill all other calls/processes)

Distributed: The programs/processes in these computers needed a way to communicate with practically any node in the world, as anyone could make a call and the system needed a way to make the distributed communication work. If a user connected to machine A wanted to talk to a user connected to machine B, we needed a way to make these two machines send messages to each other, and coordinate the actions to make.

To better convey some of these points, see how the creator of elixir explains what is possible:

Out of necessity to satisfy this requirements it gave birth to parts of the language:

Requirement => Language part

  1. Concurrency =>Processes: allow us to have concurrency since they’re isolated.
  2. Fail Fast => Supervisors: allows processes to die rather than trying to catch exceptions.
  3. Fault Tolerant =>Applications: Supervisors allow us to restart applications with a working state when they fail.
  4. Distributed => Message passing: allows us to build distributed systems, since we can pass messages between nodes easily.

And elixir has all these features too. So why elixir then?

I recommend this article: Why Elixir?

As you read is basically productivity, elixir comes with tools that help you be very productive. To name a few: iex, mix, hex, logging. It’s a very important  for the community to improve our tooling, because this ultimately lets us focus on what matters.

So when thinking why use elixir instead of Erlang is important to keep mind two additional things besides productivity:

Compatibility: Elixir will always be compatible to the upcoming versions of the VM, because of this compatibility we can call Erlang code from elixir at no additional cost.

Extensibility: Elixir knows a programming language can not have all the features developers will come up with, so with macros(meta-programming) it allows developers to build their own programming constructs for their domain problems.

In the next article I’m going to give more details about why use elixir.

You may be interested in:

Why you too should learn elixir

Leave a Reply

Your email address will not be published. Required fields are marked *