Recap
We can’t avoid dealing with state, but we have three options:
-
Shared mutability
-
Isolated mutability
-
Pure immutability
Though we’re used to shared mutability, we should avoid it as much as possible. Eliminating shared mutable state is the easiest way to avoid synchronization woes. It takes us far more effort to pick these design approaches than to pick up a library or an API. It also requires us to step back and think through how we’d design applications.
We don’t want to compromise performance in order to preserve state. So, to design with immutability, we’ll need to use modern data structures that preserve state and at the same time provide great performance.
We discussed ways to deal with state in this chapter. Next, we’ll program concurrency ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access