An Animated Introduction to Elixir
Mark Mahoney
Posted on October 20, 2022
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 tutorial, 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.
Part 1 Elixir
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
Part 2 Concurrency
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
I have more tutorials here: https://markm208.github.io
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 markm208@gmail.com. Let me know what you think!
Posted on October 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.