Header logo.
small hallucinations
homeyearstagsaboutrss

Building Complexity from Simple Ideas

I finished reading Elixir in Action. It's a great book that explains complex ideas—many of them new to me—in clear, simple language.

In each chapter, the author illustrates a set of new concepts with simple code examples and occasional exercises. As you go deeper into the book, you can clearly see how new concepts are built on the simpler ones introduced earlier. It feels recursive.

At its core, Elixir is very, very simple. You define small functions that perform specific tasks. You can specify the conditions under which these functions run using the when clause and parameter pattern matching. You then build larger functions by composing smaller ones.

The notions of pure functions and immutability go hand in hand. They may seem like constraints at first, until you realize that they free you from having to ask yourself, “Am I manipulating this list in place or not?” or “Is this pointer mutable or not?” No, you didn't change the list in place. No, it's not mutable, and you don't need to worry about pointers.

The most basic way to coordinate processes is by sending messages. A process exits after it receives and processes a message. To keep a process alive, you recursively call the function that receives messages. There are complex features, but these simple concepts remain at the core. This makes Elixir much easier for me to think about than goroutines and channels.

Go and read it.