Immutability

This Atom is Under Construction

In the beginning, memory was very expensive and rare. Early programmers did whatever they could to reuse every bit.

Changing a piece of storage rather than making a new piece with a different value was the only viable approach.

Memory remained precious during the rise of higher-level programming languages. You’ll find the programming landscape littered with schemes for preserving memory, and the resulting problems of those schemes.

Only in recent years has memory become so cheap and abundant that it has—albeit very slowly—begun to affect and benefit the programming world. One of the most fundamental changes is happening around variability.

If a piece of storage can change, it can do unexpected things and introduce errors. It might be some part of your own code that’s causing changes that surprise you, or it could be another function or process.

If that storage cannot change, however, it is no longer a potential source of program errors. The seemingly small adjustment of changing from a var to a val produces numerous benefits for the programmer.

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.