immutable

Something that cannot be changed after it is created; to change it you make a new one.

In more detail

Immutable values are safe to share between parts of a program and to use as dictionary keys, because nothing can change them afterwards. Updating one means building a new value. Numbers and strings are immutable in most languages.

Examples

In Python, int, str, tuple and frozenset are immutable; list, dict and set are not.
In the twelve-factor app a release is immutable: to change anything you create a new release. A pipeline builds one immutable artifact and promotes those same bytes, so what was tested is what runs.
Java: strings and records are immutable, though a record holding an ArrayList is only shallowly so.
Kafka records are immutable once written: an update is a new record.
In React, props, state and elements are treated as immutable; React freezes props and elements in development builds so accidental writes fail loudly.

Related terms

Taught in

References

Certification courses