An Animated Introduction to Elixir

Mark Mahoney

This is a collection of guided code walk-throughs introducing the functional, concurrent programming language, Elixir. Elixir is based on another really cool language called Erlang. If you have never programmed in the functional paradigm or explicitly created and managed processes then learning Elixir should be a fascinating introduction into these topics.

I begin by covering the basics of the Elixir programming language. Elixir is a functional programming language that relies heavily on pattern matching. Pattern matching makes it so that you almost never need to write an 'if statement'. Elixir also has immutable data. Immutable data cannot change. I discuss 'efficient immutability' and the built in data structures throughout the book. Elixir has excellent support for high order functions to process collections of data. These high order functions make it so that you rarely need to write a traditional loop. Elixir supports tail call optimizations for recursive functions which also helps reduce the number of loops that one has to write.

In the second part of this book, I cover concurrency in Elixir. Elixir makes it easy to create many communicating processes. Using processes really changes the way one thinks about solving problems. Each process has its own flow of control, call stack, and mailbox used to receive and queue messages sent from other processes. There are built in functions so that one process can send and receive messages to others. I go over a few interesting problems that use processes in this chapter.

This book covers only the basics of Elixir. If you want a more comprehensive resource, I recommend Programming Elixir by Dave Thomas. That book goes into great detail about Elixir and OTP which is used to manage complex groups of concurrent processes. These programs should serve as a good introduction to the language and functional and concurrent paradigms.

I have even more code playbacks covering different programming languages and technologies here: If you'd like to stay connected and get updates when I add new playbacks you can follow me on twitter: @markm208. You can contact me directly at Let me know what you think!

1.1 Hello Elixir!!!
1.2 Numbers and the Match Operator
1.3 Functions and More Matching
1.4 Modules and More Matching with SimpleMath
1.5 Closures
1.6 Ranges and the Enum Module
1.7 Tuples
1.8 Maps
1.9 SimpleDateFormatter Module with Maps
1.10 Lists, Matching, and Recursion
1.11 Poker Probabilities
1.12 Recursion in Elixir

2.1 Adding Tests to the Mix
2.2 Process Basics
2.3 Prime Sieve
2.4 Calendar with Processes
2.5 Poker with Processes