Skip to content

Concurrency Quote by Brian Goetz

“Immutable objects are simple. They can only be in one state, which is carefully controlled by the constructor. One of the most difficult elements of program design is reasoning about the possible states of complex objects. Reasoning about the state of immutable objects, on the other hand, is…” quote by Brian Goetz
Download Open image
““Immutable objects are simple. They can only be in one state, which is carefully controlled by the constructor. One of the most difficult elements of program design is reasoning about the possible states of complex objects. Reasoning about the state of immutable objects, on the other hand, is trivial. Immutable objects are also safer. Passing a mutable object to untrusted code, or otherwise publishing it where untrusted code could find it, is dangerous — the untrusted code might modify its state, or, worse, retain a reference to it and modify its state later from another thread. On the other hand, immutable objects cannot be subverted in this manner by malicious or buggy code, so they are safe to share and publish freely without the need to make defensive copies.””

Brian Goetz

About This Quote

Source Book: Java Concurrency in Practice, 2006

Immutable objects simplify reasoning about program state, making code safer and easier to share without defensive copying.

In simple terms: Immutability makes code safer and simpler.

Key Takeaway

Prefer immutable structures for reliability.

Themes

software engineering concurrency security

Mood

technical pragmatic

Type

educational explanatory

When to use this quote

  • API design
  • multithreaded programming
  • secure coding
  • library development

Key Concepts

immutability state management

Questions to Reflect On

  • When is mutability necessary?
  • How to balance performance and safety?
A Different Perspective

Immutability may reduce flexibility in certain designs.

4.7 out of 5 (8 ratings)

More by Brian Goetz

Explore all 13 Brian Goetz quotes

More Concurrency quotes

Browse all 13 Concurrency quotes