3 ms·
As I understand it, immutability usually refers to mutable data structures hidden behind an interface that allows the programmer to reason about things as if th
by benrbray 5y ago
As I understand it, immutability usually refers to mutable data structures hidden behind an interface that allows the programmer to reason about things as if they were immutable. The naive implementation is of course to duplicate all data whenever a change is made, but pure / immutable languages use smarter things like persistent data structures behind the scenes.
If the compiler knows the original data is never needed, it can optimize away the old copies, too. At least that's the hope, I'm not sure how true it is.
- username90 5y ago> As I understand it, immutability usually refers to mutable data structures hidden behind an interface that allows the programmer to reason about things as if they were immutable. That is the definition of an algorithm, not immutability.