Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

From Erlang to Elixir

A Practitioner’s Guide to the BEAM Ecosystem

You already know the hardest part: BEAM + OTP. Elixir gives you more places to apply it.

This book is a step-by-step migration guide for Erlang/OTP developers who want to move into the Elixir ecosystem — Web (Phoenix/LiveView), Data (Ecto/Broadway), Edge (Nerves/AtomVM), and AI (Nx/Axon/Bumblebee) — without abandoning anything they already know.


The Central Idea

Erlang/OTP provides the foundation. Elixir builds on it. The ecosystem expands into three major domains, each with flagship libraries:

flowchart TD
    OTP["Erlang / OTP"] --> EX["Elixir"]
    EX --> WEB["Web"]
    EX --> EDGE["Edge"]
    EX --> AI["AI"]
    WEB --> PHX["Phoenix<br/>LiveView"]
    EDGE --> NERVES["Nerves<br/>AtomVM"]
    AI --> NX["Nx<br/>EXLA / EMLX"]
    PHX --> P["Products"]
    NERVES --> P
    NX --> P

The arrow direction matters — knowledge flows down from Erlang/OTP through Elixir into products. You don’t replace Erlang; you extend its reach.

Both languages compile to the same BEAM bytecode and use the same OTP libraries. The runtime — schedulers, GC, distribution — is identical. Only the syntax and tooling layer differ.


Table of Contents

Part I — Foundations: What Transfers

ChTitleWhat You’ll Learn
01You Already Know the Hard PartMental model, what transfers, what doesn’t
02Syntax Translation GuideModules, structs, pattern matching, full keyword map
03Tooling: From rebar3 to MixFirst project step-by-step, deps, tests, releases
04Pipes, Enum & StreamIdiomatic data flow
05Behaviours, Protocols & StructsPolymorphism in Elixir

Part II — Language Power-ups: What Elixir Adds

ChTitleWhat You’ll Learn
06Metaprogramming & DSLsMacros, AST, why Phoenix/Ecto feel native
07Gradual TypingSet-theoretic types, mix compile diagnostics
08The Compilation Model.ex → AST → macros → BEAM bytecode
09Mix, Releases & Running OTP AppsBuild pipeline, config timing, releases, hot upgrades

Part III — The Ecosystem Map

ChTitleWhat You’ll Learn
10Phoenix & LiveViewOTP processes as web architecture
11Ecto: The Data LayerSchemas, changesets, queries, migrations, sandbox testing
12Ash: Declarative Domain ModelingResources, actions, policies, swappable data layers
13Data, Jobs & PipelinesOban, Broadway/GenStage, Explorer
14High-Level Process FrameworksReactor sagas, Jido agents, the abstraction ladder
15LivebookInteractive exploration of live systems
16Edge, IoT & MobileNerves, AtomVM, Mob/Dala

Part IV — AI on the BEAM

ChTitleWhat You’ll Learn
17Nx FundamentalsTensors, defn, autodiff
18Backends: EXLA, EMLX & HardwareThe what/how separation
19Training Models with AxonMNIST end-to-end, CNNs, transfer learning
20Bumblebee: Pre-trained ModelsHugging Face in Elixir, zero Python
21Production Inference: Nx.ServingBatched serving + the mnist_phoenix app

Part V — Under the Hood: Deep Dives

ChTitleWhat You’ll Learn
22Processes Deep DiveSpawn, mailboxes, links, monitors, exit signals
23GenServer Under the MicroscopeThe call protocol decoded, timeouts, terminate, debugging
24Supervisors Deep DiveChild specs, strategies, restart budgets, shutdown order
25Pattern Matching Deep DiveHow = executes, pins, maps/structs, binary segments
26OTP WisdomFail fast, isolation, matching as design, sagas/Reactor
27Debugging & Tracing TechniquesIO.inspect/dbg, pry, breakpoints, IEx setup, Observer, :sys.trace/:dbg/recon, config debugging

Part VI — Practice & Direction

ChTitleWhat You’ll Learn
28LLM Integration & AgentsAdapters, streaming, RAG, agent frameworks
29Architecture PhilosophyBEAM orchestrates; specialized runtimes compute
30The Migration Roadmap8-week step-by-step plan with checklists

Part VII — AI Practice Labs

Runnable labs pairing chapters with Livebooks in the part-vii-ai-practice-labs/livebooks/ collection — all-new examples, none reused from earlier chapters.

LabTitleLivebookPairs With
LAB 1Nx Optimization: Tilting Solar PanelsLAB1_nx_tilt_optimizer.livemdCh 17, 18
LAB 2Classical ML with Scholar: The Iris BotanistLAB2_scholar_iris.livemdCh 13, 17
LAB 3Axon: Untangling the Two SpiralsLAB3_axon_spiral.livemdCh 19
LAB 4CNN on Fashion-MNIST: Wardrobe VisionLAB4_cnn_fashion_mnist.livemdCh 19, 21
LAB 5Character-Level LSTM: A Tiny Text GeneratorLAB5_char_lstm.livemdCh 19, 20
LAB 6Bumblebee Semantic Search: The Support DeskLAB6_bumblebee_semantic_search.livemdCh 20, 28

How to Read This Book

Fast track (you want productivity this week): Ch 01 → 02 → 03 → 04 → 09 → 10 → 25 → 30. Ch 25 is here because it is the one chapter that names every Erlang reflex Elixir breaks — rebinding, match semantics, pinned sizes — and Ch 30’s Phase 1 assumes you have read it.

Deep dive (you want the full ecosystem picture): Read straight through. Each chapter ends with a checkpoint.

Under the hood track (you want to know exactly how it works): Part V — Ch 22 → 23 → 24 → 25 → 26 → 27, then on to Ch 28. Self-contained deep dives; drop in whenever a mechanism surprises you, or read as a unit after Ch 14.

Practice lab track (learn AI by running it): Part VII — LAB 1 → LAB 6. Each lab is a runnable Livebook in part-vii-ai-practice-labs/livebooks/: open the .livemd, run the cells top to bottom, then do the exercises. Labs are self-contained; start with LAB 1 for Nx fundamentals or jump to LAB 6 for the inference-first pattern. Setup, resource requirements, and per-lab runtimes are in the Part VII README.

Hands-on track (learn by running things): Type and run every chapter’s Step-by-step blocks as you read.


Prerequisites

  • Erlang/OTP 26+ minimum — new installs should use the latest stable line (OTP 28/29 as of writing); check Elixir’s Compatibility and deprecations for the pairing
  • Elixir 1.15+, recommended 1.20+ for gradual typing (Ch 07; verified against 1.20.3, re-verified on 1.20.4)
  • Livebook for interactive exploration (Ch 15; several chapters run code in Livebook cells):
# macOS
brew install livebook

# Or via mix
mix escript.install hex livebook

# Start a server from the repo root
livebook server   # then open http://localhost:8080

Conventions Used

  • “From Erlang you know” boxes connect new material to existing knowledge.
  • Step-by-step blocks are meant to be typed/run as you read.
  • Checkpoint sections let you verify understanding before moving on.
  • Explore More sections point to the canonical docs and next exercises.
  • Code pairs show Erlang first, Elixir second, unless noted.

Built on the elixir_ecosystem_sharing collection of Livebooks and runnable examples; the Part VII labs (LAB1–LAB6) are an all-new companion collection. MIT licensed.