Skip to content
LumenaryAcademy

Lumenary CS · Programming languages

Elixir

A friendly functional language on the Erlang virtual machine for concurrent, fault-tolerant systems, from a first program to professional practice.

Elixir is a dynamic, functional programming language created by José Valim and first released in 2012. It compiles to bytecode for the BEAM, the virtual machine built for Erlang, so every Elixir program inherits Erlang's lightweight processes, message passing and the OTP framework for building systems that keep running when parts of them fail. It is used for web applications and APIs (with the Phoenix framework), real-time features such as chat, notifications and live dashboards, data pipelines, embedded devices (Nerves) and numerical computing (Nx and Livebook).

This course is for anyone who already knows what a variable, a loop and a function are: the Start level of Lumenary CS or equivalent experience in any language. No functional programming background is needed. It starts with installing Elixir and running a first script, works through pattern matching, functions, collections, structs and protocols, and ends with processes, GenServers and supervisors, the gradual type system, testing, the everyday tools of the ecosystem and a complete small project.

To run the code, install Elixir (it needs Erlang/OTP, which the installers bring along) following elixir-lang.org/install.html. There is no official online playground; the community's free Livebook notebooks are the closest thing, and every program here also runs as a plain script with elixir main.exs. Every complete program in these lessons was run with Elixir 1.20.5 on Erlang/OTP 29 by Lumenary's test suite, and the output shown is the output it printed. The lessons were drafted with AI assistance and are awaiting review by a human computer scientist.

AI-draftedAwaiting review by a computer scientist
  • Chloe · The Designer
    “Why is the language built this way?”
  • Margaret · The Profiler
    “What does it print, and what does it cost?”
  • Gideon · The Language Lawyer
    “What exactly does the language guarantee?”

Foundations · 3 lessons

Foundations

Install Elixir, run scripts and explore in iex, and learn the core language: immutable values, pattern matching, functions, modules and the pipe operator.

  1. 1Getting started with ElixirWhere Elixir came from, why it runs on the Erlang virtual machine, and your first programs in scripts, iex and Mix. 45 min
  2. 2Values, types and pattern matchingElixir's basic types, why its data never changes, and the match operator that takes data apart. 50 min
  3. 3Functions, modules and the pipe operatorAnonymous and named functions, clauses and guards, recursion instead of loops, and pipelines that read top to bottom. 55 min

Practice · 3 lessons

Practice

Work with collections through Enum and Stream, model data with structs and protocols under the gradual type checker, and handle control flow, errors and tests the way Elixir teams do.

  1. 4Collections, Enum and StreamLists, tuples, keyword lists and maps, the Enum toolkit that processes them, comprehensions, and lazy streams for data too big to hold. 55 min
  2. 5Structs, protocols and typesNamed data shapes, polymorphism without classes, and the gradual set-theoretic type checker that infers types in Elixir 1.20. 60 min
  3. 6Control flow, errors and testingif, cond, case and with; error tuples versus exceptions; what "let it crash" really means; and tests with ExUnit. 60 min

Professional · 3 lessons

Professional

Build with processes, messages and links, structure services with GenServer and supervisors, and ship a complete project with Mix, Hex and an overview of Phoenix and LiveView.

  1. 7Processes, messages and linksThe BEAM's lightweight processes, mailboxes and selective receive, keeping state in a loop, links and monitors, and Tasks for everyday concurrency. 60 min
  2. 8GenServer, supervisors and OTPThe OTP behaviours that turn processes into reliable services, supervision trees that restart what fails, and how an application is assembled from them. 65 min
  3. 9Mix, the ecosystem and a complete projectHow professional Elixir projects are built, checked and shipped, what Phoenix and LiveView do, and a small supervised service with tests, written in idiomatic style. 70 min

Further reading and resources

  • elixir-lang.orgThe official home of Elixir: installation, news, the blog and community links.
  • Elixir documentation on HexDocsThe standard library reference and the official guides, for the current release.
  • Getting started guideThe official introduction to the language, chapter by chapter.
  • Syntax referenceElixir has no separate standard; this page and the Kernel and Kernel.SpecialForms docs are the reference for the language itself.
  • Install ElixirInstallers and package-manager instructions for Linux, macOS and Windows.
  • LivebookFree, open-source interactive notebooks for Elixir; not an official online playground, but the easiest way to experiment.
  • HexThe package registry for Elixir and Erlang libraries.