4 ms·
I don't know this for certain, but if you have immutable data structures then zippers are kind of a requirement. Many immutable data structures also have a hash
by stephen_cagle 4y ago
I don't know this for certain, but if you have immutable data structures then zippers are kind of a requirement. Many immutable data structures also have a hashing system built into them that generates a hash based on their content. So, if you have a data structure with a hash, one thing you can do that is convenient is compare just the hashes of two data structures to determine if they are equal. This is much faster than having to parse the entire data structure recursively.
Might be useful for things that are often compared, like for instance the React virtual DOM.
- taeric 4y agoThat tracks my understanding, regarding this being a bit required with immutable structures. The hash idea works even in mutable land. There are obvious caveats to not mutating data in race related scenarios. But often snapshots and other "freeze" based ideas are just as workable as moving entirely to alternatives.
- zasdffaa 4y ago> The hash idea works even in mutable land Uh, how? Other than removing it from the dictionary, mutating it then adding it back.
- taeric 4y agoSo long as you don't store things in such a way that you can't tell derived and stale data from new, the idea works exactly the same? I fully grant that immutable structures take away the concerns over data being coherent together. Such that it's easy to do without worrying about someone changing the data under you. Oddly, it can sometimes make it even harder to know that data is stale. Since updating a small part can devolve into a chore. Still fully agreed that that is the best default position.