/ˌɪˌmjuːtəˈbɪləti/

noun … “Data that never changes after creation.”

Immutability is the property of data structures or objects whose state cannot be modified once they are created. In programming, using immutable structures ensures that any operation producing a change returns a new instance rather than altering the original. This paradigm is central to Functional Programming, concurrent systems, and applications where predictable state is critical.

Key characteristics of Immutability include:

  • Thread safety: immutable data can be shared across multiple threads without synchronization.
  • Predictability: values remain constant, making reasoning, debugging, and testing easier.
  • Functional alignment: operations produce new instances, supporting function composition and declarative pipelines.
  • Reduced side effects: functions operating on immutable data do not alter external state.

Workflow example: In Scala, lists are immutable by default. Adding an element produces a new list, leaving the original untouched. This allows multiple parts of a program to reference the same data safely.

val originalList = List(1, 2, 3)
val newList = 0 :: originalList  -- Prepend 0
println(originalList)  -- Output: List(1, 2, 3)
println(newList)       -- Output: List(0, 1, 2, 3)

Conceptually, Immutability is like a printed book: once created, the text cannot be changed. To produce a different story, you create a new edition rather than modifying the original. This approach eliminates accidental alterations and ensures consistency across readers (or threads).

See Functional Programming, Scala, Concurrency, Threading.