small medium large xlarge

Programming Elixir 1.3: Functional |> Concurrent |> Pragmatic |> Fun


Cover image for Programming Elixir 1.3

Programming Elixir 1.3

Functional |> Concurrent |> Pragmatic |> Fun


Explore functional programming without the academic overtones (tell me about monads just one more time). Create concurrent applications, but get them right without all the locking and consistency headaches. Meet Elixir, a modern, functional, concurrent language built on the rock-solid Erlang VM. Elixir’s pragmatic syntax and built-in support for metaprogramming will make you productive and keep you interested for the long haul. Maybe the time is right for the Next Big Thing. Maybe it’s Elixir. This book is the introduction to Elixir for experienced programmers, completely updated for Elixir 1.3.

Customer Reviews

Dave Thomas has done it again. Programming Elixir is what every programming book aspires to be. It goes beyond the basics of simply teaching syntax and mechanical examples. It teaches you how to think Elixir.

- Bruce Tate; author

In Programming Elixir, Dave has done an excellent job of presenting functional programming in a way that is fun, practical, and full of inspirational insights into how we can rethink our very approach to designing programs. As you progress through the book, you will often find yourself smiling after discovering a certain aspect of Elixir that lets you do things in a new, more elegant way that will almost seem too natural and intuitive to have been neglected by the programming community at large for so long.

The book provides a detailed overview of Elixir and its tooling, aimed at making the development process smooth and productive. Dave explains the core parts of the Erlang runtime system, such as distribution, concurrency, and fault tolerance, that imbue Elixir with the power to write scalable and resilient applications.

- Alexei Sholik

The era of sequential programming is over—today’s high-performance, scalable, and fault-tolerant software is concurrent. Elixir is a key player in this new world, bringing the power of Erlang and OTP to a wider audience. Read this book for a head start on the next big thing in software development.

- Paul Butcher

Author of "Seven Concurrency Models in Seven Weeks"

Just like the Pickaxe book for Ruby, this book is the de facto standard for Elixir. Dave, in his impeccable style, provides a thorough coverage of the Elixir language, including data structures, macros, OTP, and even Dialyzer. This book is a joy to read, as it walks the reader through learning Elixir and the thought processes involved in writing functional programs. If you want to accelerate your mastery of the Elixir language, Programming Elixir is your best investment.

- Jim Freeze

Organizer of the world’s first Elixir Conference

This will undoubtedly become the Pickaxe for Elixir.… Thomas excitedly guides the reader through the awesomeness of Elixir. Worth picking up for anyone interested in Elixir.

- Dan Kozlowski

Programming Elixir is another smash hit from Dave Thomas. Prior to Programming Elixir I tried my hand at several functional programming languages only to trip all over myself. You can feel Dave’s enthusiasm and joy of using the language in each and every chapter. He will have you thinking about solving problems in ways you never thought of before. This book has drastically changed the way I think about programming in any language for the better.

- Richard Bishop

I’ve really enjoyed this book. It’s not just some whirlwind tour of syntax or features; I found it to be a very thoughtful introduction to both Elixir and functional programming in general.

- Cody Russell

See All Reviews

What You Need

You’ll need a computer, a little experience with another high-level language, and a sense of adventure. No functional programming experience is needed.

Contents & Extracts


  • Conventional Programming
    • Pattern Matching
      • Assignment: I Do Not Think It Means What You Think It Means.
      • More Complex Matches
      • Ignoring a Value with _ (Underscore)
      • Variables Bind Once (per Match)
      • Another Way of Looking at the Equals Sign
    • Immutability
      • You Already Have (Some) Immutable Data
      • Immutable Data Is Known Data
      • Performance Implications of Immutability
      • Coding with Immutable Data
    • Elixir Basics
      • Built-in Types
      • Value Types
      • System Types
      • Collection Types
      • Maps
      • Binaries
      • Dates and Times
      • Names, Source Files, Conventions, Operators, and So On
      • Variable Scope
      • End of the Basics
    • Anonymous Functions
      • Functions and Pattern Matching
      • One Function, Multiple Bodies
      • Functions Can Return Functions
      • Passing Functions As Arguments
      • Functions Are the Core
    • Modules and Named Functions
      • Compiling a Module
      • The Function’s Body Is a Block
      • Function Calls and Pattern Matching
      • Guard Clauses
      • Default Parameters
      • Private Functions
      • The Amazing Pipe Operator: |>
      • Modules
      • Module Attributes
      • Module Names: Elixir, Erlang, and Atoms
      • Calling a Function in an Erlang Library
      • Finding Libraries
    • Lists and Recursion excerpt
      • Heads and Tails
      • Using Head and Tail to Process a List
      • Using Head and Tail to Build a List
      • Creating a Map Function
      • Keeping Track of Values During Recursion
      • More Complex List Patterns
      • The List Module in Action
      • Get Friendly with Lists
    • Maps, Keyword Lists, Sets, and Structs
      • How to Choose Between Maps and Keyword Lists
      • Keyword Lists
      • Maps
      • Pattern Matching and Updating Maps
      • Updating a Map
      • Structs
      • Nested Dictionary Structures
      • Sets
      • With Great Power Comes Great Temptation
    • An Aside—What Are Types?
    • Processing Collections—Enum and Stream
      • Enum—Processing Collections
      • Streams—Lazy Enumerables
      • The Collectable Protocol
      • Comprehensions
      • Moving Past Divinity
    • Strings and Binaries
      • String Literals
      • The Name “strings”
      • Single-Quoted Strings—Lists of Character Codes
      • Binaries
      • Double-Quoted Strings Are Binaries
      • Binaries and Pattern Matching
      • Familiar Yet Strange
    • Control Flow
      • if and unless
      • cond
      • case
      • Raising Exceptions
      • Designing with Exceptions
      • Doing More with Less
    • Organizing a Project
      • The Project: Fetch Issues from GitHub
      • Task: Use Mix to Create Our New Project
      • Transformation: Parse the Command Line
      • Step: Write Some Basic Tests
      • Transformation: Fetch from GitHub
      • Task: Use Libraries
      • Transformation: Convert Response
      • Transformation: Sort Data
      • Transformation: Take First n Items
      • Transformation: Format the Table
      • Task: Make a Command-Line Executable
      • Task: Add Some Logging
      • Task: Create Project Documentation
      • Coding by Transforming Data
    • Tooling excerpt
      • Testing
      • Code Dependencies
      • Server Monitoring
  • Concurrent Programming
    • Working with Multiple Processes
      • A Simple Process
      • Process Overhead
      • When Processes Die
      • Parallel Map—The “Hello, World” of Erlang
      • A Fibonacci Server
      • Agents—A Teaser
      • Thinking in Processes
    • Nodes—The Key to Distributing Services excerpt
      • Naming Nodes
      • Naming Your Processes
      • I/O, PIDs, and Nodes
      • Nodes Are the Basis of Distribution
    • OTP: Servers
      • Some OTP Definitions
      • An OTP Server
      • GenServer Callbacks
      • Naming a Process
      • Tidying Up the Interface
    • OTP: Supervisors
      • Supervisors and Workers
      • Supervisors Are the Heart of Reliability
    • OTP: Applications
      • This Is Not Your Father’s Application
      • The Application Specification File
      • Turning Our Sequence Program into an OTP Application
      • Supervision Is the Basis of Reliability
      • Releasing Your Code
      • EXRM—the Elixir Release Manager
      • OTP Is Big—Unbelievably Big
    • Tasks and Agents
      • Tasks
      • Agents
      • A Bigger Example
      • Agents and Tasks, or GenServer?
  • More-Advanced Elixir
    • Macros and Code Evaluation
      • Implementing an if Statement
      • Macros Inject Code
      • Using the Representation As Code
      • Using Bindings to Inject Values
      • Macros Are Hygienic
      • Other Ways to Run Code Fragments
      • Macros and Operators
      • Digging Deeper
      • Digging Ridiculously Deep
    • Linking Modules: Behavio(u)rs and Use
      • Behaviours
      • Use and using
      • Putting It Together—Tracing Method Calls
      • Use use
    • Protocols—Polymorphic Functions
      • Defining a Protocol
      • Implementing a Protocol
      • The Available Types
      • Protocols and Structs
      • Built-In Protocols
      • Protocols Are Polymorphism
    • More Cool Stuff
      • Writing Your Own Sigils
      • Multi-app Umbrella Projects
      • But Wait! There’s More!


Dave Thomas is a programmer who likes to evangelize cool stuff. He cowrote The Pragmatic Programmer, and was one of the creators of the Manifesto for Agile Software Development. His book Programming Ruby introduced the Ruby language to the world, and Agile Web Development with Rails helped kickstart the Rails revolution.