liveBook · Manning

Structural sharing

Structural sharing is a technique in which multiple data-structure versions reuse unchanged internal portions instead of copying them.

How 3 Manning books explain it

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.

Read how Grokking Simplicity explains structural sharing →

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

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.