3 ms·
Yeah, it's also originally from the FP side. There it started I believe because people were looking how to easily make immutable updates to deep structures, sin
by ImprobableTruth 4y ago
Yeah, it's also originally from the FP side. There it started I believe because people were looking how to easily make immutable updates to deep structures, since the normal way is pretty boilerplate heavy in comparison to the mutation way of just chaining accessors for an update.
And you're close, it's about using immutability to make value equality cheap by making reference equality a proxy for it. If you don't use mutations, value equality implies reference equality and is thus equivalent (since reference equality already normally implies value equality). That means you can get away with just a single pointer comparison in comparison to completely traversing both structures. This is e.g. what React does to determine whether arguments of a component have changed.
(Well, at least I also struggle to think of a scenario where both types of equality are semantically important).