Persistent/Immutable Data Structures
In the pure immutable design for the net work-years example, we asked each person to create a new total. As we go through the chain of people, a new number is created while an old number is discarded—not a big deal since the numbers are relatively small.
The data we have to deal with may not be that small; it could be a list, tree, or matrix. We may need to work with objects that represent a boiler, a satellite, a city, and so on. We won’t naively copy these large objects over and over because that’ll lead to poor performance. Immutable or persistent data structures come to the rescue here.
Persistent data structures version their values so older and newer values stay around or persist over time without ...