Skip to content
Tutorials Center
My learning

Topics

Elixir Tutorial

Learn Elixir step by step: 48 lessons in 8 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 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.
  2. 2 Installing Elixir and Using IEx Install Erlang/OTP and Elixir on Windows, macOS or Linux, start the IEx shell, run .exs scripts and check versions with mix --version. Includes a REPL stand-in.
  3. 3 Your First Elixir Program Write your first Elixir program: print with IO.puts and IO.inspect, add comments, tell .ex from .exs, and see how modules and functions fit together.
  4. 4 Basic Types: Numbers, Atoms and Booleans Learn Elixir's basic types: big integers, floats, arithmetic with / div and rem, atoms, true, false and nil, and the simple truthiness rule behind if.
  5. 5 Strings and Binaries Work with Elixir strings: UTF-8 binaries, interpolation, heredocs, the String module, the difference between bytes and graphemes, and charlists vs strings.

Core Language

  1. 6 Pattern Matching: The = Operator Understand Elixir's match operator: destructure tuples, lists and maps, ignore parts with _, use the pin operator ^, and read a MatchError. Includes a JS matcher.
  2. 7 Immutability and Rebinding Understand why Elixir data never changes in place, how rebinding differs from mutation, and how structural sharing keeps new copies cheap.
  3. 8 Operators and Comparison Learn Elixir's arithmetic, comparison, boolean and string operators, the difference between and and &&, ranges, in, and how any two terms are ordered.
  4. 9 Tuples and Lists Learn how Elixir tuples and linked lists work, how to use head and tail, what ++ and -- cost, and when keyword lists are the right choice.
  5. 10 Maps and Structs Learn Elixir maps and structs: building them, reading with dot and bracket syntax, update syntax, nested data, defstruct and @enforce_keys.
  6. 11 Conditionals: if, unless, cond and case Choose between branches in Elixir with if, unless, cond, case and with. Learn truthiness, patterns in case, guards and how with chains steps.
  7. 12 Functions and Modules Learn how to define Elixir functions inside modules with def and defp, use anonymous functions and the capture operator, arity, defaults and attributes.
  8. 13 Multiple Clauses and Guards Learn how Elixir picks a function clause by pattern matching, how guards refine a match, which expressions are allowed in guards, defguard and clause-order traps.
  9. 14 The Pipe Operator Learn the Elixir pipe operator |>: how it passes values as the first argument, how to design pipeline-friendly functions, use then and tap, and avoid common traps.
  10. 15 Recursion and Tail Calls Learn recursion in Elixir: base and recursive cases, accumulators, body vs tail recursion, tail-call optimization on the BEAM and when to use Enum instead.

Enumerables and Data Processing

  1. 16 The Enum Module Learn the Elixir Enum module: map, filter, reduce, sort, group_by, zip, chunk_every, frequencies and more, how eager evaluation works and when to use Stream.
  2. 17 Comprehensions with for Learn Elixir for comprehensions: generators, filters, multiple generators, pattern matching, :into, :reduce, :uniq and bitstring generators, with clear examples.
  3. 18 Lazy Processing with Stream Learn Elixir Stream: lazy vs eager evaluation, Stream.map, take, iterate, unfold and cycle, streaming files line by line, and a JavaScript generator stand-in.
  4. 19 Ranges, Sorting and Custom Ordering Learn Elixir ranges with steps, Enum.sort and sort_by, sorting by several keys, descending order, comparing dates with Date.compare and how term ordering works.
  5. 20 Sigils and Regular Expressions Learn Elixir sigils such as ~r, ~s, ~w and ~D, the Regex module, named captures, replacing text, modifiers and how to write your own custom sigil.

Protocols, Errors and Tooling

  1. 21 Error Handling: Tuples, with and Exceptions Learn how Elixir handles errors with {:ok, value} and {:error, reason} tuples, the with expression, raise and rescue, try/catch, custom exceptions and let it crash.
  2. 22 Protocols and Behaviours Learn Elixir polymorphism: defprotocol and defimpl for data types, behaviours with @callback and @impl for modules, and the built-in Enumerable and Inspect protocols.
  3. 23 Metaprogramming and Macros Understand Elixir metaprogramming: the AST, quote and unquote, writing a simple defmacro, macro hygiene, __using__, and why you should avoid macros most of the time.
  4. 24 Typespecs, Dialyzer and Documentation Learn Elixir @type and @spec typespecs, @moduledoc and @doc documentation, doctests, ExDoc, Dialyzer basics and how the compiler's new set-theoretic types fit in.
  5. 25 Mix: Creating and Managing Projects Learn how Mix creates Elixir projects, what mix.exs contains, how dependencies and Hex work, and how environments and releases fit in.

Concurrency and OTP

  1. 26 Processes and Message Passing Learn how Elixir processes work: spawn, send, receive, mailboxes and self(). Includes a JavaScript actor stand-in you can run in the browser.
  2. 27 Links, Monitors and Let It Crash Learn how Elixir processes find out about each other's failures with spawn_link, Process.monitor and trap_exit, and why 'let it crash' works.
  3. 28 Keeping State in a Process Learn how Elixir keeps changing state with immutable data: recursive receive loops, request/response messages, Agent and Task, with JS stand-ins.
  4. 29 GenServer Learn GenServer in Elixir: init, handle_call, handle_cast, handle_info, naming, timeouts and state design, with a JavaScript stand-in to experiment.
  5. 30 Supervisors and Supervision Trees Learn how Elixir supervisors restart crashed processes: child specs, one_for_one, one_for_all, rest_for_one, max restarts and DynamicSupervisor.
  6. 31 Tasks and Parallel Work Run work in parallel with Elixir's Task module: Task.async and await, timeouts, Task.Supervisor, and async_stream with bounded concurrency and back-pressure.
  7. 32 ETS, Registry and Application State Learn when to keep data in ETS tables, how to find processes with Registry, what persistent_term is for, and when a plain process is still the better choice.

Real-World Elixir

  1. 33 Testing with ExUnit Write Elixir tests with ExUnit: assert and refute, describe and setup, doctests, async tests, mocks through behaviours, and an intro to property testing.
  2. 34 Files, JSON and Serialization Read and write files with Elixir's File and Path modules, stream large files line by line, encode JSON with Jason, and serialize terms with term_to_binary.
  3. 35 Ecto: Databases and Changesets Learn Ecto, Elixir's database toolkit: repos, schemas, changesets for validation, composable queries, migrations and Ecto.Multi transactions.
  4. 36 Phoenix: Web Applications Meet Phoenix, the Elixir web framework: how a request flows through the endpoint, router, plugs and controllers, HEEx templates and contexts.
  5. 37 Phoenix LiveView Learn how Phoenix LiveView builds interactive pages with server state over a websocket: mount, assigns, events, forms, PubSub updates and testing.
  6. 38 Releases, Config and Deployment Learn how to configure and ship an Elixir app: config files, runtime.exs, mix release, clustering basics and observability with Telemetry.
  7. 39 Performance and Common Pitfalls Avoid slow Elixir code: list append costs, binaries, N+1 queries in Ecto, unbounded mailboxes, large messages, and how to measure with Benchee.
  8. 40 Security Basics Learn the main security traps in Elixir and Phoenix: atom exhaustion, unsafe deserialization, SQL fragments, CSRF, XSS and keeping secrets out of code.

Projects

  1. 41 Project: Todo List with Pure Functions Build a todo list in Elixir with structs, Enum, pattern matching and formatted output, then run the same logic as a JavaScript stand-in in your browser.
  2. 42 Project: Bank Account Process Build a bank account as an Elixir process: state in a GenServer, call and cast messages, error tuples for bad requests, plus a runnable JavaScript actor model.
  3. 43 Project: Word Frequency Counter Build a word frequency counter in Elixir: stream a file line by line, split words with a regex, count with Enum.frequencies and sort the top results.
  4. 44 Project: Chat Room with Processes Build a chat room from Elixir processes: a room process keeps subscribers, broadcasts messages and uses monitors to drop users who crash or leave.
  5. 45 Project: Job Queue with Supervision Build a background job queue in Elixir: a queue process with back-pressure, workers that retry failed jobs and a supervisor that restarts crashes.

Practice and Review

  1. 46 Practice Exercises with Solutions Practice Elixir with exercises on pattern matching, recursion, Enum, structs and processes. Try each one yourself, then compare with the solution.
  2. 47 Elixir Interview Questions Prepare for an Elixir interview: clear answers on immutability, the BEAM, processes, OTP, pattern matching and tricky code snippets, with examples.
  3. 48 Elixir Cheat Sheet A one-page Elixir cheat sheet: types, operators, pattern matching, Enum, strings, processes, OTP behaviours and the most useful Mix commands.