Elixir Patterns aims to surface the powerful and unique characteristics of the Erlang virtual machine and show you how to solve everyday problems in a simple yet scalable way. Not only will you master the tools at your disposal courtesy of Erlang and the BEAM, you will also learn how to better utilize functional programming in order to achieve your goals in a clear and concise way. The idea of having a “go-to” toolbox of patterns you can leverage is an enticing one - that is what design patterns are all about! This book forgoes the abstract and instead provides concrete examples to help you better leverage the unique properties of Elixir, Erlang, and BEAM.
The Erlang programming language was first released in 1986 and to this day continues to have a tremendous impact on the field of computer programming. This impact is apparent when you look at how many other programming languages have actor model frameworks that mirror the semantics of Erlang and how many recent programming languages have emerged that make use of functional programming concepts. In addition, while many other programming languages and their runtimes require external tools in order to deal with application crashes, users of the Erlang virtual machine (or BEAM as it is colloquially called) enjoy fault-tolerant constructs that are built right into the runtime.
While the Erlang syntax may not be for everyone, we can still leverage the benefits of Erlang and the BEAM through the Elixir programming language. Elixir provides us an alternative programming language that can target the same runtime as Erlang while also leaning on the Erlang standard library. You essentially get all of the benefits of Erlang and the BEAM along with all of the tools available to you through the Elixir standard library.
This book guides you through the Erlang standard library and how you can leverage it from Elixir as well as how you can structure applications in order to make the most out of the unique runtime that is the BEAM. By the end of this book you will be comfortable constructing your own supervision trees, using processes, leaning on ETS and persistent term for when performance is a primary concern, and how you can use both the mutable and immutable data structures that are available in the Erlang standard library. In addition, you’ll learn how you can package these language and runtime primitives into reusable patterns in order to solve common problems that you may encounter in your day to day applications.
This work was written and produced entirely by the author. We are proud to be distributing it.
Alexander Koutmos has been professionally writing software for over a decade and has been primarily working with Elixir since 2015. He currently maintains a number of Elixir libraries on Hex, is a host on the BEAM Radio podcast, and wrote a book about Building a Weather Station with Nerves and Elixir.
Edit: Please note this book is now distributed by PragProg so the original thread (this post, all the way down to this post) has been merged into this thread.
You already know the basics of Elixir. Maybe you have even shipped something to production. That’s awesome! But how can you go one step further in your Elixir developer journey?
This book will help you to become a better Elixir developer by teaching you how to leverage the power of the BEAM runtime with recipes and patterns specific to Elixir/OTP.
About the book
The idea of having a “go-to” toolbox of patterns that you can leverage is an enticing one. That’s what design patterns are about. But, design patterns are usually abstract and do not leverage unique properties of your specific run-time or language. That’s how this book is different.
This book aims to surface the powerful and unique characteristics of the Erlang virtual machine (or BEAM for short) and show you how you can go about solving everyday problems in a simple yet scalable way.
Not only will you learn how to better leverage the tools that are at your disposal courtesy of Erlang and the BEAM, but you will also learn how to better utilize Functional Programming in order to achieve your goals in a clear and concise way. You’ll start off by learning about some of the Erlang standard library utilities that are available to you right out of the box, and then you’ll learn how to put those to use in your stateful GenServer powered applications.
What you’ll learn in this book:
The Erlang Standard Library Part 1
What are Data Structures
Using Queues in Erlang
The Many Set Implementations in Erlang
Arrays…in Erlang?
Using the Erlang Module for Everyday Tasks
The Erlang Standard Library Part 2
Directed Graphs with the Digraph Module
Fast Incrementers with Atomics and Counters
Blazing Fast Data Reads with Persistent Term
Using ETS and DETS for General Purpose Data Storage
Keeping Things Secret with the Crypto Module
The Elixir Standard Library
Useful Enum Module Patterns
Being Lazy with the Stream Module
Massive Concurrency with the Task Module
The Process Module
GenServers and Supervisors
Erlang Application Philosophy
What is a GenServer?
Understanding the Callbacks
The Lifecycle of a GenServer
What is a Supervisor
Combining Supervisors and GenServers
Basic GenServer Recipes
Initializing an Application
Message and Data Batching
Running Cron Jobs
Process Introspection with the Sys Module
Advanced GenServer Recipes
Rate Limiting
Work Delegator
Actor Model Design
Testing Stateful Applications
Application Release Packaging
What is an Erlang Release
Why Should you use Erlang Releases?
Handling Application Configuration
Behaviours and Protocols for Environment Specific Adapters
We’re currently targeting a full book release for the Summer. We should be releasing chapter two this coming week, which will also be a free download. PDF and Livebooks included
@hugobarauna and I just published chapter 2 of Elixir Patterns! In chapter 2 we cover some of the more advanced Erlang data structures available to us with some really helpful Livebooks to show you how they all work :).
@hugobarauna and I excited to announce the the Elixir Patterns book is in beta release! Part one of the book is complete and we’re currently working on wrapping up part 2. Each chapter has a couple of accompanying Livebook files to help you learn and experiment with the concepts in the chapter. Check it out @ https://elixirpatterns.dev/ and if you are interested in picking up a copy, you get an early beta price
Just released the next round of content (PDF and Livebooks)!. We also got a fresh new cover . Really excited about this release and happy to get it into readers hands!
We’re still running the beta price so be sure to get your copy if you haven’t already : https://elixirpatterns.dev/
Apologies for the delay with the Elixir Patterns book. My wife and our newborn both fell very ill back in February and I had to put a pause on pretty much everything from the book, open source, blogging, podcasting and everything inbetween in order to take care of the family. My wife was fairly close to death’s door, but thank God she has recovered and is improving day by day. Still a long way to go but we’re getting there.
I am hoping that I will be back to writing the book in a few weeks. And after that hopefully back to doing some open source work. It’s been a long road for the family and I appreciate all the support from the Elixir community .
I’m very sorry to hear that. I’m glad to hear they are getting better and my thoughts are with you. I do hope you did not think my query was at all ‘pushy’ - this was not my intention at all. Your priority has got to be your family and I am grateful for authors like you in the Elixir community willing to spend the time to produce the brilliant resources that you do. All the best to you for the future.
Appreciate the kind words my friend . Didn’t take your comment as pushy at all, just wanted to let you know what was going on and when you can expect some updated content .
@hugobarauna and I have some fantastic news…the Elixir Patterns books is complete and in release candidate!!
The eighth and final chapter dives into:
Building a Scalable Actor Model with Caching Support: Learn how to architect a high-performance, fault-tolerant system using GenServers, ETS, and DynamicSupervisor.
Implementing a Fault-Tolerant ETS Cache: Discover techniques to make your ETS caches resilient to failures, ensuring that your system can recover and maintain state even after unexpected process crashes.
Adapter Pattern in Elixir: Understand how to use Elixir’s behaviours to implement the adapter pattern, allowing you to easily swap out dependencies at run-time or compile-time.
Here is a sneak peak at the final boss supervision tree
This is the first release candidate of Elixir Patterns which means that the book’s content is complete, but we expect minor adjustments and potential errata. If you haven’t so already, be sure to pick up your copy at: https://elixirpatterns.dev/
Just bought the book. I really liked the way content was outlined. Looking forward to reading this. Skimmed the first two chapters quickly and I like what I see
Thank you for writing this.
Update: Just looked at some of the LiveBooks. I can see myself browsing the livebook after finishing a section, resulting in a pretty unique experience for a book. I hope more books follow this pattern.
Thank you for the kind words and we really appreciate the support!!
I’m happy to hear that you like the unique experience that the book + Livebooks offer. That was very much our intention when we kicked off this project and it’s nice to know that we placed the correct bet .
The Livebooks also make it super convenient for copying and pasting code into your own projects (very much inspired by the TailwindUI experience). Just the other day I needed the skeleton for a cron job GenServer and I copy and pasted right from the Elixir Patterns Livebook .
@hugobarauna and I are in the process of collecting feedback during the Release Candidate phase and will be updating the content accordingly over the next few weeks.
If you purchased the book we’ll be sure to email you the final copy once it is released!