You Already Have (Some) Immutable Data

Forget about Elixir for a moment. Think about your current programming language of choice. Let’s imagine you’d written this:

 
count = 99
 
do_something_with(count)
 
print(count)

You’d expect it to output 99. In fact, you’d be very surprised if it didn’t. At your very core, you believe that 99 will always have the value 99.

Now, you could obviously bind a new value to your variable, but that doesn’t change the fact that the value 99 is still 99.

Imagine programming in a world where you couldn’t rely on that—where some other code, possibly running in parallel with your own, could change the value of 99. In that world, the call to do_something_with might kick off code that runs in the background, passing it ...

Get Programming 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.