Immutable collection
An immutable collection is a collection whose contents cannot be changed after it is created.
Data-Oriented Programming: Reduce software complexity
Immutable data is data whose stored value cannot be modified after creation, requiring changes to be represented by new data versions.
- How it is used
- Uses immutable collections to communicate between components, manage versions of state, and simplify generic data flows.
- How deep it goes
- Explains freezing, persistent data structures, structural sharing, versioned state, and library APIs; defers detailed concurrency control to later treatment.
- Examples
- Demonstrates Java immutable lists and maps, JavaScript freezing, Lodash FP updates, Immutable.js maps, and library-state versions.
- What you can do after
- Apply it via Java, JavaScript, Lodash FP, or Immutable.js to preserve collections and create changed versions.
Read how Data-Oriented Programming: Reduce software complexity explains immutable collection →
The Art of Code
A collection whose membership and structure cannot be modified after construction.
- How it is used
- Uses immutable collections and data to reduce side effects in shared inputs and functional pipelines.
- How deep it goes
- Explains a shared-reference mutation bug and non-destructive alternatives, then distinguishes fixed references from deep immutability.
- Examples
- Uses country-prefixed product IDs to contrast destructive filtering with stream counting and a fixed list.
- What you can do after
- Diagnose shared-list mutation and apply Java streams or List.of to avoid unintended changes.
F# in Action: A Revised Edition of Get Programming with F#
An immutable object or value is one whose state or contents cannot be changed after creation.
- How it is used
- Models application state as successive values rather than changing an object in place.
- How deep it goes
- Works through mutable and immutable gas-state updates and discusses performance qualitatively, without detailing collection implementations.
- Examples
- Compares a mutable shopping basket with returned basket states and traces a gas tank through successive drive calls.
- What you can do after
- Practice/perform it by passing F# state into functions and using their returned values for subsequent operations.
Read how F# in Action: A Revised Edition of Get Programming with F# explains immutable collection →
The Joy of JavaScript
An object whose fields cannot be changed after creation and whose state is represented without in-place mutation.
- How it is used
- Keeps existing array and value-object state intact while functional transformations produce results.
- How deep it goes
- Shows array-operation contrasts and a frozen Money implementation, while treating immutable design as a choice rather than requiring it for every object.
- Examples
- Uses block validation with filter, map, and reduce, plus a frozen Money object whose arithmetic returns new values.
- What you can do after
- Build it from scratch as a frozen Money-style value object, or apply array transformations without changing the original array.
Read how The Joy of JavaScript explains immutable collection →
Functional Programming in JavaScript
The property of data or state not changing after it has been created.
- How it is used
- Frames functional programming as a way to minimize moving parts and shared state.
- How deep it goes
- Introduces immutability through stateful counter and array-transformation contrasts, deferring deeper treatment.
- Examples
- Contrasts an external counter mutation and an array-squaring loop with functional expressions using `map`.
- What you can do after
- Evaluate/understand when external state changes make computations unpredictable and when input-to-output expressions avoid that dependency.
Read how Functional Programming in JavaScript explains immutable collection →
Idiomatic Rust
Immutability is the property that existing values or data structures cannot be modified after they are created.
- How it is used
- Uses immutable collections to preserve earlier values while making data changes easier to reason about.
- How deep it goes
- Works through Cow-based construction and im Vector cloning, but leaves full crate details to their documentation.
- Examples
- Demonstrates a Cow-backed list whose method returns a new version and an im Vector updated after cloning.
- What you can do after
- Build it from scratch with Cow, or apply it via im while retaining earlier collection versions.
Fabulous Adventures in Data Structures and Algorithms
An immutable data structure is a data structure whose contents cannot be changed after it is created.
- How it is used
- Preserves earlier collection states for undo-redo and supports branching work such as backtracking search.
- How deep it goes
- Builds stacks from linked lists, develops collection interfaces, and analyzes performance; recommends standard-library collections for production.
- Examples
- Branches an immutable stack into shared-tail versions and reverses a linked list without changing the original.
- What you can do after
- Build it from scratch as a basic immutable stack and judge when shared state makes immutable versions efficient.
Read how Fabulous Adventures in Data Structures and Algorithms explains immutable collection →
Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform
Immutability is a paradigm in which an established artifact is not modified in place and changes are made by creating a new version.
- How it is used
- Uses infrastructure as code to replace resources safely, reduce drift, support controlled deployments, and recover from failures.
- How deep it goes
- Explains definitions, migration ordering, blue-green deployment, and roll-forward recovery without descending into provider-specific internals.
- Examples
- Uses Python server upgrades, machine images, brownfield network migration, green networks, and service-account permission repair.
- What you can do after
- Operate immutable IaC by replacing resources, migrating brownfield infrastructure, testing dependent changes, and rolling forward repairs.
100 Java Mistakes and How to Avoid Them
An immutable collection is a collection whose state cannot be changed after construction.
- How it is used
- Prevents runtime failures when code attempts to mutate Java collections whose modification operations are unsupported.
- How deep it goes
- Explains mutation restrictions, inconsistent API behavior, null-related migration risks, and limits of static analysis rather than collection internals.
- Examples
- Uses Arrays.asList, Map.keySet, List.of, a conditional sanitize result, List.copyOf, and Set.of null lookups.
- What you can do after
- Diagnose/debug with it by identifying unsafe mutation calls and choosing consistently mutable or unmodifiable return values.
Read how 100 Java Mistakes and How to Avoid Them explains immutable collection →
Grokking Simplicity
Data or state whose represented values cannot be modified after creation.
- How it is used
- Uses immutable data to turn data reading and transformation into calculations while isolating actions and mutable state.
- How deep it goes
- Implements copy-on-write for JavaScript arrays and objects, extends it to nested data and untrusted code, and addresses performance tradeoffs.
- Examples
- Demonstrates pizza-business data, shopping carts, JavaScript array copying, nested structures, and ValueCells.
- What you can do after
- Build it from scratch with copy-on-write array and object operations, or apply defensive copying when code cannot be trusted.
Read how Grokking Simplicity explains immutable collection →
Python Workout: 50 ten-minute exercises
A property of an object whose state cannot be changed after the object is created.
- How it is used
- Explains why Python programs replace immutable values instead of modifying them in place.
- How deep it goes
- Defines immutability, demonstrates failed string mutation, and connects it to functions, threads, dictionaries, and functional programming.
- Examples
- Uses indexed string assignment, rebinding, list-versus-tuple comparisons, and immutable data transformations.
- What you can do after
- Apply immutable-value reasoning when choosing collections, passing data to functions, and replacing rather than modifying values.
Read how Python Workout: 50 ten-minute exercises explains immutable collection →
Tiny Python Projects: Learn coding and testing with puzzles and games
- How it is used
- Uses immutability to explain string replacement, safe state representation, and the contrast between tuples and mutable lists.
- How deep it goes
- Demonstrates failed assignments, reconstruction, list conversion, and named-tuple safety without examining Python object internals.
- Examples
- Shows string replacement, random character mutation, shuffled word middles, dictionary keys, and tic-tac-toe state tuples.
- What you can do after
- Apply immutability by rebuilding strings, converting them to editable lists, or choosing tuples and named tuples for protected state.
The Quick Python Book, Fourth Edition
Immutability is the property of an object or data structure that prevents its contents from being changed after creation.
- How it is used
- Uses immutable collections for fixed contents and as candidates for dictionary keys or set members.
- How deep it goes
- Explains permitted operations, reassignment, nested mutability, and hashability, including restrictions on tuple keys.
- Examples
- Demonstrates tuple assignment errors, string editing through lists, and function arguments with shared mutable lists.
- What you can do after
- Apply it in Python by choosing immutable types, producing replacement values, and checking whether a tuple can serve as a dictionary key.
Read how The Quick Python Book, Fourth Edition explains immutable collection →
Get Programming: Learn to code with Python
- How it is used
- Distinguishes collections that cannot change from lists and dictionaries that can, then explains why dictionary keys must be immutable.
- How deep it goes
- Defines immutability and explains variable rebinding through memory diagrams; contrasts it with direct changes to a list.
- Examples
- Uses a grocery list, memory diagrams, and dictionary key lookups to contrast replacing an object with changing one.
- What you can do after
- Evaluate/understand whether an assignment replaces a collection or modifies it, and why dictionary keys must remain unchanged.
Read how Get Programming: Learn to code with Python explains immutable collection →
Kotlin in Action, 2E
Immutability is the property that an object's state cannot change after the object is created.
- How it is used
- Supports functional programming by keeping shared state stable for simpler testing, reasoning, and multithreaded code.
- How deep it goes
- Distinguishes immutable collections from read-only views and explains aliasing, thread-safety limits, and immutable data-class updates.
- Examples
- Uses collection source-and-target typing and a Customer data-class copy with a changed postal code.
- What you can do after
- Evaluate/understand whether Kotlin collection access is truly immutable or merely read-only, and choose copying or synchronization accordingly.
Read how Kotlin in Action, 2E explains immutable collection →
Python How-To
Immutability is the property of a data structure or object whose contents cannot be changed after creation.
- How it is used
- Uses tuples for fixed task metadata and lists for task collections that change.
- How deep it goes
- Explains modification errors and distinguishes fixed tuple references from mutable contained objects.
- Examples
- Demonstrates tuple modification errors, a tuple containing lists, and a frozen data class.
- What you can do after
- Apply immutability with Python tuples and frozen data classes to protect fixed data from unintended changes.
Elixir in Action, Third Edition
Immutable data is data whose value cannot be changed after it has been created, so modifications produce new versions instead of altering existing values.
- How it is used
- Uses immutable transformations to organize Elixir programs into composable functions and preserve consistent data versions.
- How deep it goes
- Explains rebinding, side effects, structural sharing, list and tuple costs, and recursive hierarchical updates without descending into runtime implementation.
- Examples
- Demonstrates tuple replacement, list construction, pipelined transformations, and nested to-do-list updates with put_in.
- What you can do after
- Apply it via Elixir transformations, pipelines, rebinding, and put_in updates while retaining earlier data versions.
Read how Elixir in Action, Third Edition explains immutable collection →
Functional Design and Architecture: Examples in Haskell
Immutability is the property that a value or data structure cannot be changed after it is created.
- How it is used
- Uses immutability to avoid shared state and support predictable functional computation.
- How deep it goes
- Explains immutable bindings and mutation avoidance, then connects them to deterministic functions and concurrency risks.
- Examples
- Uses Scala `val` and `var`, Haskell `IORef`, and a numeric calculation to contrast bindings with destructive updates.
- What you can do after
- Understand how avoiding shared mutation supports predictable computation and reduces a class of concurrency bugs.
Read how Functional Design and Architecture: Examples in Haskell explains immutable collection →
Learn Go with Pocket-Sized Projects
Immutability is the property of a value or object whose state cannot be changed after construction.
- How it is used
- Uses immutability to represent safe, predictable value objects such as money and calculated calendar periods.
- How deep it goes
- Explains hidden fields, construction, derived methods, and thread safety, but does not detail collection-specific mutation mechanisms.
- Examples
- Demonstrates immutable Currency, Amount, Decimal, and FormattedWeek values with hidden fields and read-only methods.
- What you can do after
- Build it from scratch in Go by hiding fields, constructing complete values, and exposing non-mutating methods.
Read how Learn Go with Pocket-Sized Projects explains immutable collection →
100 C++ Mistakes and How to Avoid Them
Immutable data is data whose value cannot be changed after it has been created.
- How it is used
- Guides Rational class design by treating numbers as values that should not change after construction.
- How deep it goes
- Recommends removing mutators and possibly accessors, without developing a mutable alternative.
- Examples
- Uses a Rational class with setters as the problematic example and a revised interface without setters.
- What you can do after
- Evaluate whether a class should expose mutators or accessors and preserve a value after construction.
Read how 100 C++ Mistakes and How to Avoid Them explains immutable collection →
The Well-Grounded Rubyist, Fourth Edition
Immutability is the property of data or objects that prevents their state from being changed after creation.
- How it is used
- Uses immutability to discuss safer Ruby code and functional programming, including situations involving multiple threads.
- How deep it goes
- Explains symbol immutability, Ruby freezing, and frozen strings, while warning that freezing does not guarantee all attributes are immutable.
- Examples
- Uses symbols, a frozen Record instance, a mutable string constant, and frozen string literals with mutable copies.
- What you can do after
- Operate on Ruby objects with `freeze` and `frozen?`, and create mutable string copies with `dup`, `String.new`, or unary `+`.
Read how The Well-Grounded Rubyist, Fourth Edition explains immutable collection →
JavaScript in Depth
The property of a string value that prevents its contents from being changed after creation.
- How it is used
- Explains why string updates create new values and how immutability affects concatenation performance.
- How deep it goes
- Defines immutability, demonstrates failed indexed assignment, and connects it to V8 string sharing and concatenation costs.
- Examples
- Uses indexed assignment, loop-built strings, and generated HTML tables to expose mutation and allocation behavior.
- What you can do after
- Diagnose/debug with it, identify ineffective string mutation, and recognize repeated concatenation as a potential allocation and performance problem.
Read how JavaScript in Depth explains immutable collection →
Apache Kafka in Action
Immutability is the property of data that prevents its existing contents from being changed or removed after creation.
- How it is used
- Uses immutability to preserve ordered histories and safely exchange data across service boundaries.
- How deep it goes
- Explains the property through logs, debugging, restoration, and service coupling, without detailing collection implementation.
- Examples
- Uses a diary, application logs, database commit logs, and data exchanged between services as concrete examples.
- What you can do after
- Evaluate/understand how immutable histories support debugging, state restoration, and independent service evolution.
Read how Apache Kafka in Action explains immutable collection →
100 Go Mistakes and How to Avoid Them
Immutability is the property that a value or data object cannot be changed after creation.
- How it is used
- Diagnoses allocation and copying costs caused by treating immutable strings as mutable accumulation buffers.
- How deep it goes
- Explains immutability through allocation behavior, byte copying, builder buffering, preallocation, and conversion examples.
- Examples
- Uses repeated concatenation, strings.Builder, Builder.Grow, byte-slice sanitization, and a byte-to-string mutation experiment.
- What you can do after
- Diagnose unnecessary allocations and choose strings.Builder or byte-slice processing for appropriate workflows.
Read how 100 Go Mistakes and How to Avoid Them explains immutable collection →
Acing the Frontend Interview
Immutability is the practice of preserving existing values and representing changes by creating new values instead of modifying the originals.
- How it is used
- Frames immutability as an interview-relevant functional-programming practice for writing predictable, maintainable JavaScript.
- How deep it goes
- Defines immutability, explains its relationship to pure functions, and demonstrates one array transformation without covering implementation internals.
- Examples
- Uses a nums array mapped into doubled values while retaining the original array.
- What you can do after
- Apply immutability by refactoring code and using functional collection transformations.
Read how Acing the Frontend Interview explains immutable collection →
Deep Learning with JAX
The property of values not being modified in place after creation, as emphasized for JAX arrays here.
- How it is used
- Uses immutable array updates to support pure functions and JAX transformations.
- How deep it goes
- Explains the mutation error, functional replacements, and efficiency caveats, but defers a full treatment of functional programming.
- Examples
- Demonstrates NumPy assignment, JAX assignment failure, .at[].set updates, and out-of-bounds indexing modes.
- What you can do after
- Apply JAX's .at[] API to replace common in-place array updates with functionally pure expressions.
Read how Deep Learning with JAX explains immutable collection →
React Quickly, Second Edition
Data whose existing structures are not modified, with changes represented by creating new structures.
- How it is used
- Uses immutable data to support declarative programming and read-only React component properties.
- How deep it goes
- Defines mutation versus new-structure creation, demonstrates filtering, and stops short of advanced immutable-data techniques.
- Examples
- Uses password filtering, array push as a contrast, and frozen props inspected with Object.isFrozen().
- What you can do after
- Apply it via array filter to derive results without editing the original collection or React props.
Read how React Quickly, Second Edition explains immutable collection →
Object-Oriented Software Design in C++
An immutable object is an object whose observable state cannot be changed after it is created.
- How it is used
- Uses immutability to protect employee records and illustrate implementation hiding through controlled object access.
- How deep it goes
- Descends from absent setters to pointer-based change leaks, then demonstrates copy-based remedies.
- Examples
- Uses Date objects and Employee birthdates, testing external and getter-returned pointers before and after copying.
- What you can do after
- Diagnose/debug with it by finding pointer-based change leaks and applying defensive copies at construction and access.
Read how Object-Oriented Software Design in C++ explains immutable collection →
Secrets of the JavaScript Ninja, Third Edition
An immutable collection is a collection whose contents cannot be modified after the collection is created.
- How it is used
- Prevents unexpected changes when collections are shared across API boundaries.
- How deep it goes
- Contrasts mutation with replacement, then shows TypeScript read-only types and Immer drafts for producing modified copies.
- Examples
- Uses read-only NinjaState with an array and map, then demonstrates changes through an Immer draft.
- What you can do after
- Apply it via Immer’s produce function to create a modified copy through draft mutations.
Read how Secrets of the JavaScript Ninja, Third Edition explains immutable collection →
Advanced Algorithms and Data Structures
Immutability is the property that an existing object or data structure cannot be changed after creation, so updates produce a new structure or version.
- How it is used
- Reduces shared state in parallel computation and lets readers access shared resources without locks.
- How deep it goes
- Defines updates as new structures and explains concurrency benefits and trade-offs, without detailing an immutable collection implementation.
- Examples
- Uses appending to a list and updating a cache to illustrate creating new structures.
- What you can do after
- Understand how immutability affects concurrent reads, shared state, and the cost of updates.
Read how Advanced Algorithms and Data Structures explains immutable collection →
Also covered in
- Data-Oriented Programming in JavaIn early access (MEAP)
- C# Concurrency: Asynchronous and multithreaded programming
- Unit Testing Principles, Practices, and Patterns
- Python Workout, Second Edition
- Akka in Action, Second Edition
- Learn Haskell by Example
- Software Design for Python Programmers
- Architecting an Apache Iceberg Lakehouse
- Learn AI-Assisted Python Programming, Second Edition
- Julia as a Second Language
- Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
- Code Like a Pro in Rust
What to know first
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
- stateState is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- functional programmingFunctional programming is a programming paradigm that expresses computation through the evaluation and composition of functions, typically favoring immutable data and minimizing mutable state and side effects.
- listA list is an ordered collection of elements arranged in a sequence.
Related concepts
- statecontrasts with · State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- mutable objectcontrasts with · A mutable object is an object whose state can be changed after it is created.
- objectkind of · An object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
- persistent data structurecontrasts with · A persistent data structure preserves access to earlier versions when updates produce new versions rather than modifying existing ones.
- read-only collection interfacecontrasts with · A read-only collection interface exposes collection contents and traversal operations without exposing mutation operations through that interface.
- tupleimplemented by · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
Questions about immutable collection
What is immutable collection?
An immutable collection is a collection whose contents cannot be changed after it is created.
Which Manning books explain immutable collection?
Data-Oriented Programming: Reduce software complexity, The Art of Code, F# in Action: A Revised Edition of Get Programming with F#, The Joy of JavaScript, Functional Programming in JavaScript, Idiomatic Rust, Fabulous Adventures in Data Structures and Algorithms, Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform and 22 more.
What should I know before learning immutable collection?
Manning books that teach immutable collection usually introduce Map, state, functional programming and list first.
What is the difference between immutable collection and state?
An immutable collection is a collection whose contents cannot be changed after it is created. State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
What is immutable collection a kind of?
Immutable collection is a kind of object. An object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





























