Purely Dysfunctional Data Structures in Java
summary
Immutable data structures shrink the bug surface but force copying and extra GC unless you use structural sharing to reuse nodes; a persistent singly linked list gives O(1) prepend but O(n) append, persistent queues use two lists for amortized O(1), and practical persistent maps use a Hash Array Mapped Trie with a 32-way branching factor (tree depth around 6–7 for millions of entries). Java got immutable small-list classes, Scala 2.14 adds compressed HAMT workarounds, and Java libraries like Vavr and Cyclops provide implementations to try.
AI-written summary · about
chapters (11)
- 0:00Introduction and speaker background
- 1:54Immutability in Java and its challenges
- 7:18Defining immutability in Java
- 11:57Designing good immutable APIs
- 15:57Persistent data structures overview
- 23:07Persistent linked lists explained
- 25:59Immutability and thread safety trade-offs
- 29:35Persistent sets and trees
- 31:26Persistent queues and performance
- 35:21Persistent maps and radix trees
- 39:19Summary and key takeaways
