Skip to content

Repository files navigation

From Erlang to Elixir

From Erlang to Elixir — A Practitioner's Guide to the BEAM Ecosystem

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
Loading

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

Ch Title What You'll Learn
01 You Already Know the Hard Part Mental model, what transfers, what doesn't
02 Syntax Translation Guide Modules, structs, pattern matching, full keyword map
03 Tooling: From rebar3 to Mix First project step-by-step, deps, tests, releases
04 Pipes, Enum & Stream Idiomatic data flow
05 Behaviours, Protocols & Structs Polymorphism in Elixir

Part II — Language Power-ups: What Elixir Adds

Ch Title What You'll Learn
06 Metaprogramming & DSLs Macros, AST, why Phoenix/Ecto feel native
07 Gradual Typing Set-theoretic types, mix compile diagnostics
08 The Compilation Model .ex → AST → macros → BEAM bytecode
09 Mix, Releases & Running OTP Apps Build pipeline, config timing, releases, hot upgrades

Part III — The Ecosystem Map

Ch Title What You'll Learn
10 Phoenix & LiveView OTP processes as web architecture
11 Ecto: The Data Layer Schemas, changesets, queries, migrations, sandbox testing
12 Ash: Declarative Domain Modeling Resources, actions, policies, swappable data layers
13 Data, Jobs & Pipelines Oban, Broadway/GenStage, Explorer
14 High-Level Process Frameworks Reactor sagas, Jido agents, the abstraction ladder
15 Livebook Interactive exploration of live systems
16 Edge, IoT & Mobile Nerves, AtomVM, Mob/Dala

Part IV — AI on the BEAM

Ch Title What You'll Learn
17 Nx Fundamentals Tensors, defn, autodiff
18 Backends: EXLA, EMLX & Hardware The what/how separation
19 Training Models with Axon MNIST end-to-end, CNNs, transfer learning
20 Bumblebee: Pre-trained Models Hugging Face in Elixir, zero Python
21 Production Inference: Nx.Serving Batched serving + the mnist_phoenix app

Part V — Under the Hood: Deep Dives

Ch Title What You'll Learn
22 Processes Deep Dive Spawn, mailboxes, links, monitors, exit signals
23 GenServer Under the Microscope The call protocol decoded, timeouts, terminate, debugging
24 Supervisors Deep Dive Child specs, strategies, restart budgets, shutdown order
25 Pattern Matching Deep Dive How = executes, pins, maps/structs, binary segments
26 OTP Wisdom Fail fast, isolation, matching as design, sagas/Reactor
27 Debugging & Tracing Techniques IO.inspect/dbg, pry, breakpoints, IEx setup, Observer, :sys.trace/:dbg/recon, config debugging

Part VI — Practice & Direction

Ch Title What You'll Learn
28 LLM Integration & Agents Adapters, streaming, RAG, agent frameworks
29 Architecture Philosophy BEAM orchestrates; specialized runtimes compute
30 The Migration Roadmap 8-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.

Ch Lab Livebook Pairs With
31 Nx Optimization: Tilting Solar Panels LAB1_nx_tilt_optimizer.livemd Ch 17, 18
32 Classical ML with Scholar: The Iris Botanist LAB2_scholar_iris.livemd Ch 13, 17
33 Axon: Untangling the Two Spirals LAB3_axon_spiral.livemd Ch 19
34 CNN on Fashion-MNIST: Wardrobe Vision LAB4_cnn_fashion_mnist.livemd Ch 19, 21
35 Character-Level LSTM: A Tiny Text Generator LAB5_char_lstm.livemd Ch 19, 20
36 Bumblebee Semantic Search: The Support Desk LAB6_bumblebee_semantic_search.livemd Ch 20, 21, 22

How to Read This Book

Fast track (you want productivity this week): Ch 01 → 02 → 03 → 04 → 09 → 10 → 30.

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, plus Ch 27 for debugging and tracing. 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 — Ch 31 → 36. Each chapter pairs 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 Ch 31 for Nx fundamentals or jump to Ch 36 for the inference-first pattern.

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)
  • 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 (LAB1LAB6) are an all-new companion collection. MIT licensed.

About

This is a guide for Erlang developers can go to Elixir ecosystem faster.

Topics

Resources

Stars

13 stars

Watchers

0 watching

Forks

Releases

Contributors