Start free trial
Trending New Genres Authors
EnglishEnglish
EspañolSpanish
简体中文Chinese
繁體中文Chinese (Traditional)
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Searching...
SoBrief
Programming Elixir

Programming Elixir

Functional |> Concurrent |> Pragmatic |> Fun
Build Elixir programs that stay readable under concurrency and recover cleanly when workers fail.
by Dave Thomas 2013 287 pages
4.28
500+ ratings
Listen
Immersive
V2.3
Amazon Kindle Audible
Try Full Access for 3 Days
Unlock listening & more!
Continue

Key Takeaways

Design programs as pipelines that transform data, not objects that hide it.

Start with the data. Elixir invites programmers to treat a program as a series of functions, each turning one value into another. Instead of building a hierarchy of objects that alter private state, write small operations that can be tested and recombined. The Unix shell offers a familiar model: focused tools pass results along a pipeline, so each step can do one job clearly.

Follow the transformation. The book’s sample command-line application retrieves GitHub issues, decodes the response, reshapes the data, sorts it, selects a requested number, and formats a table. Each stage becomes a function, and the pipe operator makes the sequence resemble the plan. The code is easier to inspect because the data’s journey is visible instead of scattered across state-changing method calls.

Analysis

What's striking is how this design makes the path of a value part of the program's explanation. That resembles a well-designed data workflow: each stage has a clear input and output, so failures can be localized and components reused. It also creates a useful distinction between transformations and effects, such as reading a network response or printing a table. The approach is not a universal replacement for stateful designs. Some problems center on long-lived entities and changing state. The practical test is whether the pipeline clarifies the work, rather than forcing every problem into a sequence of awkward conversions.

Treat matches as structural questions, and immutable values as safe shared knowledge.

Read the equals sign differently. In Elixir, `=` attempts a match. A pattern such as a three-part list can extract its elements, while a literal in the pattern can require a particular value. Repeated variables must match the same value within that match, and the pin operator can require an already-bound value. Function clauses use the same logic to select behavior based on arguments.

Keep old values intact. Elixir data cannot be changed in place. A transformation produces a new value, while unchanged portions of a structure can be shared rather than copied wholesale. This makes a list passed to another function predictable: the other function cannot silently alter it. The same rule applies to maps and structs. Double-quoted strings are UTF-8 binaries, while single-quoted forms are lists of character codes, an important distinction when choosing string operations.

Analysis

Immutability changes the cost of reasoning, not just the syntax. If a value cannot change behind a function's back, a reader can follow data across function boundaries without tracing every possible mutation. That property is particularly helpful when many processes operate at once. Structural sharing also answers the intuitive objection that every update must duplicate an entire collection. Still, immutable values do not guarantee a correct program: a transformation can be logically wrong, and external effects remain mutable. Pattern matching is most useful when it makes assumptions explicit, not when dense patterns become a puzzle of their own.

Compose small functions with pipes, and let Enum or Stream handle collections.

Give functions useful roles. Functions in Elixir are values, so they can be passed to operations such as `map` and `reduce`. A recursive list function can split a list into its head and tail, process one element, and continue; an accumulator carries a running result without mutable global state. The book builds its own mapping and reduction functions to show the mechanics, then recommends using the standard collection tools for everyday work.

Choose eager or lazy work. `Enum` processes a collection and usually builds a result collection at each step. `Stream` instead describes work to perform as values are requested. Mapping ten million numbers and then taking five can be wasteful with eager processing, while a stream can produce just those five. Streams can also read files incrementally, though the book notes that this may trade speed for lower memory use or earlier processing.

Analysis

The combination of higher-order functions and pipelines makes data processing composable, while the Enum and Stream distinction gives the programmer control over when computation happens. This is the same design tension found in database query plans and other lazy systems: delaying work can avoid unnecessary results, but it can also make timing and effects less obvious. A stream is not automatically faster; the book's file example is slower than its eager alternative. The useful question is whether the whole collection is needed, or whether processing can stop early or keep pace with incoming data.

Use cheap isolated processes and messages instead of shared mutable state.

Make concurrency the normal tool. Elixir runs on the Erlang virtual machine, whose lightweight processes have separate state and communicate by sending messages. A process waits for messages, matches each one, performs work, and can recurse to handle the next. Since processes do not share ordinary mutable memory, programmers avoid many races and locks that complicate shared-state concurrency.

Scale the idea carefully. In a book example, a chain of one million processes passed a number along in about seven seconds on the author's 2011 laptop, after he raised the VM's default process limit. The chain ran sequentially, so it demonstrates low process overhead, not million-way parallel speed. Named VM nodes can communicate across machines, but access depends on a shared cookie, which the book warns is transmitted in plain text over network connections.

Analysis

The model makes isolation a default boundary: a process owns its state, and messages are the explicit interface. That is a strong way to reduce accidental interference, but it shifts rather than removes concurrency questions. Message ordering, failure handling, and queues still matter, and creating a process per item can overwhelm a system if work arrives faster than it is consumed. The million-process demonstration is memorable because it overturns the assumption that processes must be expensive, yet its sequential chain should not be mistaken for a performance benchmark of parallel computation.

Design failures to kill workers, then let supervisors restore service.

Contain the crash. OTP, the Erlang and Elixir framework for building and managing applications, supplies standard server and supervision patterns. A `GenServer` handles calls and casts through callbacks, keeping its state in one process. A supervisor monitors workers and restarts them according to a chosen strategy. This lets one failed worker stop without necessarily taking down the whole application.

Preserve what matters. The book's sequence-number server restarts after a bad update, but a fresh process initially forgets its old number. The solution is a separate stash process that outlives the worker. The worker saves its number before termination, and the replacement retrieves it on startup. The example shows that recovery and state preservation are separate design problems: restarting a process restores activity, but not automatically its prior memory.

Analysis

Supervision is a practical expression of fault containment: instead of assuming every component behaves perfectly, the system defines what happens when one does not. The stash example also clarifies an important reliability distinction. A restart policy is not persistence; state held only in another process is still vulnerable if that process or the entire node fails. Real systems must decide which state can be reconstructed, which must survive failures, and whether retried work is safe to repeat. The framework supplies structure, but the application's failure semantics still require deliberate design.

Use Mix, tests, and documentation to make transformations dependable.

Turn an experiment into a project. Mix creates a conventional project layout, compiles code, manages dependencies, runs tests, and can build a command-line executable. In the GitHub issues example, a test catches a real parsing mistake: the optional issue count arrives as text, not an integer. The mismatch becomes visible in a focused test, and the conversion is fixed before the full program is assembled.

Make examples executable. ExUnit provides ordinary tests, while doctests run examples embedded in function documentation. The project also demonstrates configuration files, logging, external libraries, and a final pipeline that prints selected issues as a table. These tools are not side material: they let small transformations be checked independently, dependencies be reproduced, and usage examples be verified instead of trusted on sight.

Analysis

The project's strongest lesson is that a clean architecture is supported by a feedback loop. Small functions make testing manageable, and tests expose mismatches at boundaries, where data changes representation or enters from outside. Doctests add a useful second contract: documentation examples must remain executable. This is especially valuable in a language ecosystem that changes quickly. Tests do not prove the program correct, however, and examples can overrepresent happy paths. The same discipline should cover malformed responses, network failures, and assumptions about external services.

Use Tasks for background work, Agents for state, and GenServers for custom servers.

Pick the lightest abstraction. A `Task` runs a function in a separate process; `Task.await` retrieves its result when the caller needs it. An `Agent` is a process that holds state, which callers read or update by supplying functions. The book's word-frequency example stores a dictionary in an Agent, while parallel dictionary loading uses one Task per file.

Step up when needed. A `GenServer` is appropriate when a process needs a more tailored message interface, explicit callbacks, or a place in a supervision design. Tasks and Agents use OTP machinery too, but hide much of its detail. The book's advice is to use the simplest option that fits, and to place a module around the interface so that the implementation can change without forcing changes throughout the application.

Analysis

These abstractions are best understood as different amounts of control over a process, not as competing brands. A Task emphasizes a result, an Agent emphasizes a stored value, and a GenServer exposes a protocol for interacting with a process. That distinction can prevent unnecessary callback code. It also helps teams communicate intent: a stateful Agent is easy to adopt, but complicated rules and invariants may belong behind a more explicit server interface. The wrapper-module suggestion is a useful form of dependency inversion, preserving callers while implementation details evolve.

Extend Elixir sparingly: macros reshape syntax, protocols add type-specific behavior.

Use the right extension point. A macro receives code before ordinary execution and can return code that the compiler inserts into the program. This allows syntax extensions, but also makes behavior harder to inspect. The book's guiding restraint is to prefer a function whenever a function can do the job. `use` provides a convenient way for a module to inject setup or imports into another module.

Separate interfaces from implementations. A behaviour lists callbacks a module promises to implement, as with OTP server callbacks. A protocol defines operations whose implementations can be supplied separately for different data types, enabling polymorphic functions such as inspection or collection processing. Type specifications document expected inputs and outputs, and Dialyzer can flag some contradictions. These tools expand the language, but each adds concepts that should earn their complexity.

Analysis

Elixir's extensibility is unusually coherent: code can be represented and manipulated, behaviours describe module-level contracts, and protocols dispatch on data type. Those mechanisms serve different purposes, so confusing them can create brittle designs. Macros are particularly powerful because they act at compilation time, but their generated code can obscure control flow and debugging. Protocols offer a more constrained route to polymorphism, while type specifications improve communication and analysis without turning the language into a fully enforced static type system. Extension is most valuable when it makes repeated domain logic clearer for its users.

Analysis

Programming Elixir is a pragmatic tutorial organized around a change in viewpoint. It begins by challenging familiar habits, then teaches the language's functional foundations, builds a complete command-line project, and uses that foundation to introduce concurrency and OTP. Its examples are designed as stepping stones: pattern matching explains function clauses, recursion explains list processing, and the GitHub issue tool turns those ideas into a maintainable pipeline. The book then widens the frame from a single function to a system of processes, nodes, servers, and supervisors.

Its most durable contribution is the connection between immutable data transformations and isolated processes. Each simplifies a different source of complexity. Immutable values make local reasoning easier; processes reduce shared-state coordination; supervision gives failures an explicit place in the design. The result is not that concurrency or failure disappears, but that the code can express boundaries more directly.

That distinction matters. A supervisor can restart a process, but cannot decide whether discarded work should be repeated, whether a side effect already occurred, or what information must survive a node failure. The book's stash example makes the gap visible: recovery depends on where state lives. Similarly, lightweight processes encourage concurrency, but useful throughput still depends on workload, message volume, and available resources. These are design responsibilities, not properties granted automatically by a runtime.

The text is intentionally an introduction rather than a language reference. It teaches enough syntax to help readers ask better questions and invites them to experiment, consult documentation, and practice. Its 2014 examples reflect the Elixir and Erlang ecosystem of that period, so code details and library recommendations are historically situated. The architectural ideas remain the stronger takeaway: keep transformations legible, make process communication explicit, and treat recovery as part of system design rather than an emergency patch.

Summary in 30 Seconds
Elixir programs become easier to reason about when small functions transform immutable data through visible pipelines. Pattern matching selects behavior from a value's structure, while Enum handles eager collection work and Stream avoids processing values until needed. Lightweight processes communicate through messages, reducing shared-state coordination. Supervisors can restart failed workers, but recovery does not restore lost state unless it is stored elsewhere. Mix, tests, and documentation help keep each transformation dependable.
Contains spoilers

Last updated:

Report Issue

Review Summary

4.28 out of 5
Average of 500+ ratings from Goodreads and Amazon.

Programming Elixir is highly praised for its clear explanations and effective teaching of Elixir concepts. Readers appreciate its coverage of functional programming, concurrency, and OTP basics. The book is considered an excellent introduction for newcomers to Elixir, with well-structured content and helpful exercises. Some readers found certain sections lacking depth, particularly in OTP and advanced topics. The writing style is generally engaging, though a few found it condescending. Overall, it's recommended for those interested in learning Elixir, especially when complemented with additional resources.

Your rating:
4.6
159 ratings
Want to read the full book?

Glossary

Pattern matching

Structural value matching

A way to compare a value with a pattern and bind variables where their structures correspond. Patterns can include literal values, nested collections, and wildcards, so they both extract information and enforce conditions. Elixir uses pattern matching in assignments, function arguments, and message handling.

Immutability

Unchangeable data values

The rule that a value cannot be altered after it is created. Operations that appear to update data return a new value, while the original remains available to other code. Elixir can reuse unchanged parts of structures, so producing a new value does not necessarily mean copying every element.

Pipe operator

Pass results between functions

The |> operator takes the result of the expression on its left and passes it as the first argument to the function on its right. Chaining pipes presents a sequence of transformations in processing order, making data flow easier to read than deeply nested function calls.

Stream

Lazy enumerable pipeline

A composable description of collection operations that computes values only when a consumer requests them. Unlike eager Enum operations, a Stream can avoid building intermediate collections and can process large, delayed, or infinite sequences incrementally. Its laziness can save memory or enable early results, though it does not guarantee faster execution.

Actor model

Isolated message-driven processes

A concurrency model in which independent processes maintain separate state and communicate by messages. Elixir processes are virtual-machine processes rather than operating-system processes. Their isolation reduces the need to coordinate access to shared mutable memory, while message handling defines how each process responds.

OTP

Erlang application framework

The collection of Erlang and Elixir conventions, libraries, and runtime facilities used to structure and manage concurrent applications. OTP includes behaviours for servers and supervisors, application startup conventions, and tools for monitoring and updating running systems. It supplies reusable infrastructure, not automatic guarantees of application correctness.

GenServer

Callback-based process server

An OTP behaviour for implementing a process that handles requests and maintains state. A module supplies callbacks such as handle_call and handle_cast; the GenServer machinery provides the message loop and passes the current state to those callbacks. Modules commonly wrap its calls and casts in a simpler public interface.

Supervisor

Worker monitor and restarter

An OTP process that monitors child workers or other supervisors and applies a configured response when a child terminates. A supervisor can restart a failed process, helping isolate failures and restore service. Restarting does not itself restore the process's prior state, which must be reconstructed or stored elsewhere.

Task

Asynchronous function process

An Elixir abstraction for running a function in a separate process. Task.async returns a descriptor that can be passed to Task.await to retrieve the result. Tasks can also be linked to callers or started under supervision, making them useful for bounded background work without writing a complete server.

Agent

Process holding state

An Elixir abstraction that stores state inside a background process and exposes functions for reading or updating it. Callers provide functions that operate on the current state, while the Agent controls the process and state transition. It offers a simpler interface than implementing a GenServer when state management is the primary need.

Protocol

Type-specific function dispatch

A named set of functions whose implementations are defined separately for different data types. Protocols let a function behave polymorphically without modifying the modules that define those types. They are used to extend operations such as inspection and enumeration in a structured, type-directed way.

Behaviour

Required module callbacks

A declared interface consisting of callback functions that an implementing module is expected to provide. Behaviours document and validate module-level contracts, often producing compile-time warnings when required callbacks are missing. OTP uses behaviours to standardize components such as servers and supervisors.

FAQ

What's Programming Elixir about?

  • Functional Programming Focus: Programming Elixir introduces readers to functional programming using the Elixir language, emphasizing immutability and data transformation.
  • Concurrency and Scalability: It highlights Elixir's strengths in building concurrent and distributed applications, leveraging the Erlang VM for fault tolerance and scalability.
  • Practical Learning Approach: The author, Dave Thomas, uses a hands-on approach with code examples and exercises to solidify understanding and application of concepts.

Why should I read Programming Elixir?

  • Comprehensive Coverage: The book provides a thorough exploration of Elixir, suitable for both beginners and experienced programmers, covering fundamental and advanced topics.
  • Focus on Concurrency: It delves into Elixir's ability to handle concurrent programming effortlessly, invaluable for developers working on scalable applications.
  • Expert Guidance: Written by a respected figure in the programming community, it offers insights and best practices to help readers avoid common pitfalls.

What are the key takeaways of Programming Elixir?

  • Functional Programming Principles: Readers learn about immutability, first-class functions, and higher-order functions, foundational for effective Elixir code.
  • Concurrency and Fault Tolerance: The book emphasizes Elixir's concurrency model and building fault-tolerant applications using OTP.
  • Real-World Examples: Numerous examples and exercises illustrate how to apply Elixir concepts in real-world scenarios, reinforcing learning.

What are the best quotes from Programming Elixir and what do they mean?

  • "Programming Should Be About Transforming Data": This quote encapsulates the philosophy that programming is more about data manipulation than state management.
  • "Let the process crash.": Reflects the philosophy of fault tolerance, encouraging systems that recover from failures rather than preventing them.
  • "Elixir is here to free you from antiquated concurrency mechanisms": Emphasizes Elixir's modern approach to concurrency, simplifying scalable application development.

How does Programming Elixir approach teaching functional programming?

  • Hands-On Examples: Uses practical examples and exercises to teach functional programming concepts, promoting active engagement.
  • Incremental Learning: Concepts are introduced incrementally, building on previous knowledge for a comprehensive understanding.
  • Emphasis on Immutability: Highlights the importance of immutability, explaining how it leads to safer and more predictable code.

What is the significance of pattern matching in Elixir?

  • Core Concept: Pattern matching is fundamental in Elixir, allowing developers to destructure data easily and bind variables concisely.
  • Control Flow Simplification: It simplifies control flow by enabling functions to have multiple clauses matching different patterns.
  • Versatile Tool: Used extensively in function definitions, case statements, and variable assignments, making it a versatile tool in Elixir programming.

How does immutability affect programming in Elixir?

  • No Side Effects: Immutability ensures data cannot be changed after creation, eliminating side effects and simplifying code reasoning.
  • Concurrency Benefits: Simplifies concurrent programming by removing the need to manage shared state, reducing synchronization complexity.
  • Data Transformation Focus: Encourages thinking in terms of data transformations, leading to cleaner and more functional code.

How does Programming Elixir address concurrency in Elixir?

  • Actor Model Introduction: Introduces the actor model of concurrency, where processes communicate through message passing.
  • Lightweight Processes: Elixir allows the creation of lightweight processes, enabling many tasks to run simultaneously without threading issues.
  • Fault Tolerance Emphasis: Leverages the Erlang VM's capabilities to create resilient applications, emphasizing fault tolerance in concurrent systems.

What is the role of the Enum and Stream modules in Elixir?

  • Collection Processing: The Enum module provides functions for processing collections, allowing iteration, filtering, and data transformation.
  • Lazy Evaluation: The Stream module enables lazy evaluation, computing values only when needed, improving performance and reducing memory usage.
  • Composability: Both modules support composable operations, allowing developers to build complex data processing pipelines clearly and concisely.

What is the significance of OTP in Programming Elixir?

  • Framework for Applications: OTP is a set of libraries and design principles for building robust applications in Elixir.
  • Supervision Trees: Explains creating supervision trees for monitoring and restarting processes, crucial for application reliability.
  • Concurrency Model: OTP's concurrency model allows scalable applications handling many processes simultaneously, vital for leveraging Elixir's strengths.

How does Programming Elixir explain the concept of processes?

  • Lightweight Processes: Elixir processes are lightweight and managed by the Erlang VM, allowing thousands of concurrent processes.
  • Message Passing: Emphasizes the message-passing model for process communication, promoting decoupling and fault tolerance.
  • Supervision and Fault Tolerance: Details using supervisors to monitor processes and handle failures gracefully, essential for resilient applications.

What advanced topics are covered in Programming Elixir?

  • Macros and Metaprogramming: Explains macros for extending the language and creating domain-specific constructs.
  • Protocols for Polymorphism: Introduces protocols for achieving polymorphism, promoting code reuse and flexibility.
  • Umbrella Projects: Discusses managing multiple related applications within a single project structure, useful for large codebases.

About the Author

Dave Thomas is a respected author in the programming community, known for his contributions to Ruby and Elixir literature. He co-authored "The Pragmatic Programmer" and wrote the influential "Programming Ruby" (the "Pickaxe book"). Thomas has a reputation for clear, engaging writing that effectively conveys complex concepts to readers. His work on "Programming Elixir" demonstrates his ability to introduce new languages and paradigms to experienced developers. Thomas's books often feature practical examples and exercises, reflecting his pragmatic approach to teaching programming. His expertise spans multiple languages and paradigms, making him a valuable resource for developers seeking to expand their skills.

Download PDF

To save this Programming Elixir summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.40 MB     Pages: 19

Download EPUB

To read this Programming Elixir summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 1.40 MB     Pages: 24
Want to read the full book?
Follow
Listen
Home
Swipe
Library
Get App
Try Full Access for 3 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
Read unlimited summaries. Free users get 3 per month
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
—
❤️ Unlimited Bookmarks
Free users are limited to 4
—
📜 Unlimited History
Free users are limited to 4
—
📥 Unlimited Downloads
Free users are limited to 1
—
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 26,000+ books. That's 12,000+ hours of audio!
Day 2: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 3: Your subscription begins
You'll be charged on Nov 24,
cancel anytime before.
Consume 2.8× More Books
2.8× more books Listening Reading
Our users love us
1M+ readers
Trustpilot Rating
TrustPilot
4.6 Excellent
This site is a total game-changer. I've been flying through book summaries like never before. Highly, highly recommend.
— Dave G
Worth my money and time, and really well made. I've never seen this quality of summaries on other websites. Very helpful!
— Em
Highly recommended!! Fantastic service. Perfect for those that want a little more than a teaser but not all the intricate details of a full audio book.
— Greg M
Save 62%
Yearly
$119.88 $44.99/year/yr
$3.75/mo
Monthly
$9.99/mo
Start a 3-Day Free Trial
3 days free, then $44.99/year. Cancel anytime.
Unlock a world of fiction & nonfiction books
26,000+ books for the price of 2 books
Read any book in 10 minutes
Discover new books like Tinder
Request any book if it's not summarized
Read more books than anyone you know
#1 app for book lovers
Lifelike & immersive summaries
30-day money-back guarantee
Download summaries in EPUBs or PDFs
Cancel anytime in a few clicks

Why one summary?

Scanner
Find a barcode to scan

⭐
⭐
⭐
We have a special gift for you
Open
38% off
DISCOUNT FOR YOU
⭐
⭐
⭐
$79.99
$49.99/year
Only $4.16 per month
Continue
2 taps to start, super easy to cancel
Settings
General
Widget
Loading...