Sep 28, 2016
Table of contents:
Whilst it does provide an introductory section on Elixir and the syntax, the real heart of the book is focused on OTP.
The book also touches upon important Elixir related topics such as distribution, testing, and type specifications that are a little bit more advanced than the standard topics covered by more introductory Elixir learning material.
The Little Elixir & OTP Guidebook is written by Benjamin Tan Wei Hao, a Ruby and Elixir developer based in Singapore.
The book opens with a whirlwind tour of the language including setting up your environment, running elixir in
iex, data types, and pattern matching.
I think there is a lot of benefit in rereading, or reading more examples of material that you think you understand because it will likely ignite something new and you may come away with a better understanding. But you could skip this chapter if you feel like you are already up to speed with the general usage of the language.
The next section of the book concentrates on giving the reader a good introduction to processes and using
This book is focused around using OTP and so it is imperative that the reader has a good understanding of processes and
GenServer before delving into the more complicated aspects of OTP.
Again, if you have explored other Elixir resources, such as the books we’ve already looked at, there probably isn’t a great deal here that you will find to be new.
However, when I was reading through these chapters I found that it really put into place the things I felt that I understood about this very important topic of learning Elixir.
In chapters 6 and 7 we walk through building out a worker pool from scratch using the tools we’ve learned so far including Mix, GenServer, and Supervisors. The project is split into 4 phases of development that has us incrementally improve the design of the application.
For me, this was really the best guide to building out Elixir an application that I’ve found so far.
Before reading these chapters I felt I had a good understanding of each component of a typical Elixir application. But there was something conceptually missing from my understanding that I just couldn’t put my finger on.
After building out this worker pool application I felt I had a much better understanding of how to design and build an Elixir application using the basic building blocks of the language.
I also found that I no longer needed to look at the documentation quite so much.
When reading technical books, it’s easy to just briefly look at the code sections to get an understanding of what is going on. But the process of actually typing the code out is half of the benefit of reading a book like this.
Not only will it help you get into the mental habit of typing out the code, but it will also force you to debug and deal with errors when you inevitably get something wrong.
The next section of the book focuses on distribution, load balancing, and fault tolerance.
Again whilst other learning resources had touched upon these topics, I found that this book took that next step. You walk through a couple of different scenarios, and you get to set up different methods for dealing with distribution, load balancing, and fault tolerance.
I definitely found that I had a better understanding of these topics after, but I feel like a whole book could probably be dedicated to this area of learning Elixir, Erlang, and OTP.
The final section of the book is dedicated to testing.
I feel like I have a very good understanding of testing in other programming languages, but one of the things that I was unsure of when learning Elixir is how to test concurrent code.
In the first part of this section, we look at the property-based testing tool, QuickCheck. This is where you define a specification, and then the unit tests are auto generated and run against your code. This allows you to test hundreds or thousands of examples against your code without having to write the tests yourself.
The second part of this section looks at Concuerror for testing concurrent code. We look at a couple of different examples of problems that can arise with concurrent code such as deadlocks and race conditions. These are often problems that you would not face if you were simply playing with your code in
Overall the testing section of the book is really just an introduction. I suspect whole books could be written around the idea of writing tests for concurrent code. And so whilst this book does not provide all of the answers it does point you in the right direction to begin to learn more on the subject.
This is a great little book for learning more about Elixir and OTP.
I think it’s probably worth reading the other books first so you have a better foundation of Elixir. You could probably get away with just reading this book, but I think it is worth your time to read the other books first.
If you are struggling with the bigger picture of how to build Elixir applications and how to effectively use OTP I think this is a great first step. Walking through building the worker pool application is the best explanation of this topic I had found up to this point, and typing out the code and seeing it working in the Erlang observer really cemented that understanding.
The other sections of the book are a little light on information. Arguably you could probably drop the section on getting started with Elixir and focus this book to people who already have that foundation from other resources.
You will probably finish reading this book with more questions than you started with. It doesn’t try to answer everything question, but it does shed light on areas such as distribution and testing.
If you are looking for the next step in your learning of Elixir and OTP, I would definitely recommend picking up a copy of The Little Elixir & OTP Guidebook.