
A perfectly good introduction to the Elixir language, although it didn’t have anything specific to learning functional programming in it beyond getting used to doing things the Elixir way. I guess it had more recursion than most introductory programming books… It feels like a terrible introduction in comparison to Dave Thomas’ Programming Elixir though, since it stops totally short of introducing the Actor model and OTP, which are unique strengths of Elixir, but that’s obviously a longer book to read.
The book starts with Elixir fundamentals: immutable variables, the pipe operator
(|>), and pattern matching with case and tuples to control flow without
relying on imperative reassignment:
# Chapters 2 and 3 build intuition for immutability and pattern matching:
defmodule AbilityScore do
def parse_score(input) do
case Integer.parse(input) do
:error ->
{:error, "Invalid score: #{input}"}
{score, _remainder} ->
modifier = (score - 10) / 2
{:ok, modifier}
end
end
end
The middle chapters spend significant time on recursive functions, demonstrating
how list head-tail decomposition handles unbounded loops before transitioning to
the Enum module’s higher-order functions:
# Chapter 4 leans into recursive list traversal and pattern matching heads/tails:
defmodule StringList do
def upcase([]), do: []
def upcase([head | tail]), do: [String.upcase(head) | upcase(tail)]
end
# Chapter 5 replaces explicit recursion with higher-order functions and capture syntax:
total_cost =
[10, 25, 40]
|> Enum.map(&(&1 * 1.08))
|> Enum.reduce(0, &+/2)
The final chapters move toward application design with typed structs, guard clauses, and separating pure domain logic from impure I/O boundaries:
# Chapters 6 and 7 structure domain data using structs and boundary functions:
defmodule Character do
@enforce_keys [:name]
defstruct [:name, health: 100, mana: 50]
def attack(%Character{health: hp} = target, damage) when damage >= 0 do
new_hp = max(hp - damage, 0)
%{target | health: new_hp}
end
def alive?(%Character{health: hp}), do: hp > 0
end