Elixir vs. Mutable Objects
Since Elixir is a functional programming language, it does not have objects. The language also has a strong focus on immutability. In Elixir we transform data rather than mutate it.
Said another way: OO changes. FP copies.
While this difference may be subtle and might even seem inefficient, it’s transformational. Many of Elixir’s most important benefits flow directly from this design decision. In this section, we’re going to look at what those benefits might be, and why they matter to you. Let’s take that apart.
Understanding Mutation
Mutable objects bundle three concerns that are distinct in Elixir: state, behavior, and time. Take this example:
| dictionary.store("key", "value") |
If this were like most object-oriented ...
Get Adopting Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.