top | item 45970071

(no title)

edem | 3 months ago

For immutability to be effective you'd also need persistent data structures (structural sharing). Otherwise you'll quickly grind to a halt.

discuss

order

epolanski|3 months ago

Why would you quickly grind to a halt.

iLemming|3 months ago

Without persistent data structures (structural sharing) - every change requires copying the entire data structure, memory usage explodes, time complexity suffers, GC pressure increases dramatically.

With persistent data structures - only the changed parts are new; unchanged parts are shared between versions; adding to a list might only create a few new nodes while reusing most of the structure; it's memory efficient, time efficient, multiple versions can coexist cheaply. And you get countless benefits - fearless concurrency, easier reasoning, elimination of whole class of bugs.