Structural sharing
Structural sharing is a technique in which multiple data-structure versions reuse unchanged internal portions instead of copying them.
Data-Oriented Programming: Reduce software complexity
Structural sharing is a data-management technique in which related versions reuse unchanged portions of the same underlying structure.
- How it is used
- Creates immutable state versions efficiently while supporting calculation, commit, history, undo, and time travel.
- How deep it goes
- Explains path copying, recursive implementation, persistent structures, and linked-list sharing, while deferring concurrent mutations.
- Examples
- Uses a library catalog update, recursive JavaScript code, linked lists, historical state versions, and Lodash FP.
- What you can do after
- Build it from scratch with recursive path copying, apply it through Lodash FP, and implement simple undo with version references.
Read how Data-Oriented Programming: Reduce software complexity explains structural sharing →
Grokking Simplicity
Structural sharing is a data-structure technique in which multiple versions reuse references to common portions of their representation.
- How it is used
- Uses copy-on-write to update nested immutable data without copying unchanged objects.
- How deep it goes
- Explains shallow copies, shared references, nested update paths, and safety, while deferring specialized persistent structures.
- Examples
- Demonstrates shopping-cart price and quantity updates using array slices, Object.assign(), and nested replacement.
- What you can do after
- Apply via JavaScript’s slice() and Object.assign() to implement copy-on-write updates for nested data.
Functional Programming in Scala, Second Edition
Structural sharing is the reuse of unchanged substructures between immutable data structures instead of copying them.
- How it is used
- Preserves immutable list values while avoiding unnecessary copying during functional updates.
- How deep it goes
- Explains reuse, persistence, runtime costs, and copying limits through linked-list operations, but defers alternative data-structure implementations.
- Examples
- Uses Cons and Nil lists, tail, drop, dropWhile, append, and init to expose reuse and copying behavior.
- What you can do after
- Apply structural sharing by implementing immutable list operations that reuse available substructures and copy only necessary prefixes.
Read how Functional Programming in Scala, Second Edition explains structural sharing →
Related concepts
- persistent data structureused by · A persistent data structure preserves access to previous versions because updates create new versions without modifying existing ones.
- shallow copyproduced by · A shallow copy duplicates a data structure’s outer container while retaining references to its nested values rather than copying them recursively.
- immutable collectionuses · An immutable collection is a collection whose membership and contents cannot be changed after creation.
- hierarchyuses · A hierarchy is an organization of entities into nested or ordered levels connected by parent-child, containment, or broader-to-narrower relationships.
- multi-version state managementproduces · Multi-version state management maintains multiple immutable versions of system data and advances a reference to select the current version.
- immutable functionused by · An immutable function is a deterministic function that does not modify its inputs or externally observable state.
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.


