Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 48 ยท Getting Started

What Is Elixir?

Meet Elixir, a functional language that runs on the Erlang VM (the BEAM). Learn where it came from, what makes it good at concurrency, and where teams use it.

Elixir is a functional programming language built for programs that must stay up, talk to many users at once, and keep working when parts of them fail. Josรฉ Valim created it, and the first public release came in 2012. Its syntax looks friendly and a little like Ruby, but underneath it is a very different animal: Elixir code runs on the BEAM, the virtual machine that was designed at Ericsson for telephone switches.

This lesson explains what that means in plain words. You will learn what the BEAM is, why Elixir shares its ideas with Erlang, what "functional" and "concurrent" mean in practice, and what kinds of products are built with it. You will also learn how the examples on this site work, because Elixir itself does not run in your browser here.

A language on top of the BEAM

Think of three layers:

  • Erlang is a language created in the 1980s at Ericsson to run phone networks. Those systems could not be switched off for maintenance, so Erlang was designed around lightweight concurrency and recovering from failures.
  • OTP (Open Telecom Platform) is Erlang's standard library of building blocks: servers, supervisors, state machines and more. The name is historic; it is used far beyond telecom.
  • The BEAM is the virtual machine that runs the compiled code. It schedules millions of tiny processes across your CPU cores.

Elixir is a modern language that compiles to the same bytecode as Erlang. Because of that, Elixir can call any Erlang library with no wrapper and no speed penalty, and Erlang can call Elixir. You inherit decades of battle-tested engineering and get a more approachable syntax, macros, a build tool called Mix and a package manager called Hex.

flowchart LR
  A["Elixir source<br/>(.ex / .exs)"] --> B["Compiler"]
  C["Erlang source<br/>(.erl)"] --> B
  B --> D["BEAM bytecode<br/>(.beam)"]
  D --> E["BEAM virtual machine<br/>schedulers + processes"]

Elixir and Erlang both compile to BEAM bytecode, so they share one runtime and can use each other's libraries.

What makes it different

Four big ideas

Functional Data never changes; functions return new data.
Concurrent Millions of tiny processes at once.
Fault tolerant Let a process crash, then restart it.
Distributed Processes can talk across machines.

These ideas come from Erlang and the BEAM.

1 / 2

Functional. In Elixir you do not change values; you build new ones. A list is never modified in place, and there are no loops that update a counter. You write small functions, match the shape of data, and chain them together. Later lessons on immutability, pattern matching and the pipe operator show how natural this becomes.

Concurrent. A BEAM process is not an operating-system thread. It is a very small unit that has its own memory and its own mailbox. A single laptop can run hundreds of thousands of them. Processes never share variables; they send each other messages. Because nothing is shared, there are no locks to forget and no data races on ordinary data.

Fault tolerant. Instead of trying to prevent every error with defensive code, Elixir encourages a "let it crash" style. A process that hits a problem stops, and a supervisor process notices and starts a fresh copy in a known good state. Only the broken part is affected. You will meet this in supervisors.

Preemptive scheduling. The BEAM interrupts processes after a small amount of work, so one slow request cannot starve the others. That gives the platform steady, predictable latency under load.

A first look at the code

Here is a short piece of real Elixir. You do not need to understand everything yet; just notice how readable it is:

ELIXIR
defmodule Greeter do
  def hello(name) do
    "Hello, #{name}!"
  end
end

IO.puts(Greeter.hello("Ana"))
# prints: Hello, Ana!

A module groups functions, def defines a function, and #{...} puts a value inside a string. The last line calls the function and prints the result.

Processes are the star of the show. This is what sending a message looks like in real Elixir:

ELIXIR
pid = spawn(fn ->
  receive do
    {:ping, from} -> send(from, :pong)
  end
end)

send(pid, {:ping, self()})

receive do
  :pong -> IO.puts("got pong")
end

spawn starts a process, send puts a message in its mailbox and receive waits for a matching message. Processes and message passing covers this fully.

What runs on this site

This site can run many languages in your browser or on a server, but Elixir and Erlang are not installed here. So the Elixir code in these lessons is read-only: you can read it, copy it and run it on your own machine once you have installed Elixir.

To still give you something to experiment with, many lessons include a JavaScript stand-in. It is a small program that imitates the idea (matching a pattern, passing a message, rebinding a name) so you can see the behavior. A stand-in is not real Elixir, and each lesson says what is real and what is imitated.

Here is the first one: two "processes" that have a mailbox each and talk by sending messages. It is only a model of the idea, built with JavaScript async functions.

JS Stand-in: two processes and a mailbox

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The two objects never touch each other's data. They only drop messages into mailboxes, which is the core of how Elixir programs are structured.

The second stand-in shows "cheap processes": we create ten thousand of these little actors and count messages handled. Real BEAM processes are far lighter than JavaScript objects with closures, but the point is the style: many small workers instead of one big one.

JS Stand-in: ten thousand tiny workers

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Where Elixir is used

Elixir fits systems that handle many connections or events at once and must stay available:

  • Web applications and APIs with the Phoenix framework, including real-time features such as chat, live dashboards and notifications through Phoenix LiveView.
  • Messaging and real-time platforms where each user connection is a process.
  • Data pipelines and background jobs, where supervised workers retry failed work.
  • Embedded and IoT devices through the Nerves project.
  • Machine learning and numerical work through libraries such as Nx, though Python remains the main language of that field.

It is a strong choice when concurrency and reliability matter. It is not the first pick for heavy number crunching on one thread, because the BEAM favors responsiveness and fairness over raw single-thread speed, and heavy native work is usually delegated to other code. It also has a smaller job market and library catalog than languages such as JavaScript or Python, which is a real consideration for a team.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the BEAM?

    The BEAM is the Erlang virtual machine. Elixir compiles to BEAM bytecode, which is why it can use Erlang libraries directly.
  2. 2. How do Elixir processes share data with each other?

    Processes have isolated memory. They communicate only by sending messages to each other's mailboxes.
  3. 3. What does the 'let it crash' idea mean?

    A failure is confined to one process. A supervisor then starts a fresh copy, so the rest of the system keeps working.
  4. 4. Can you run real Elixir code in the TryIt editors of this site?

    Elixir and Erlang are not installed on the site, so the Elixir code is read-only. The runnable examples are JavaScript stand-ins.

Summary

  • Elixir is a functional language that compiles to BEAM bytecode and runs on the Erlang virtual machine.
  • It inherits OTP from Erlang: lightweight processes, message passing, supervisors and distribution.
  • Data is immutable; programs are built from small functions and pattern matching.
  • Processes are isolated and cheap, and failures are handled by restarting them.
  • Elixir shines for real-time, high-concurrency and always-on systems.
  • On this site Elixir code is read-only, and the runnable examples are honest JavaScript stand-ins.

Next: Installing Elixir and Using IEx