4 ms·
How does inmutable-js fit into this discussion? My limited understanding is it defers the copy decision and then can limit it to the area needed. Wouldn't that
by heisenbit 9y ago
How does inmutable-js fit into this discussion? My limited understanding is it defers the copy decision and then can limit it to the area needed. Wouldn't that lead in most cases to a better performance?
- olfactory 9y agoI'm wondering this too.
- dlbucci 9y agoIf you have immutable objects (doesn't even have to be ImmutableJS, you can just decide to never mutate object properties), then there's really not even a need for cloning at that point. The reason you would clone an object is to avoid mutating the original object, which you don't need to worry about when everything is immutable.
- DiThi 9y agoExcept that you need to copy _something_ at some point to modify values (or more precisely, having another object that is the same but with X change). In theory everything is re-created with a change, but in practice only the changed objects are copied.
- danmaz74 9y agoImmutable objects aren't very useful if you can't create mutated copies...
- Jach 9y agoI don't know the details of immutable-js but generally an immutable 'deep copy' shouldn't be different than a 'copy' that you'd normally get by e.g. passing the thing by value. Two symbols point to the same root that defines the data structure, the symbols are value-equal, but not id-equal (at the symbol comparison level). The usual concerns about deep copying don't really apply, since if you try to mutate either of them, neither of them will be affected, but a new piece of data will be created that has an id-different path to the root of the structure but everything unmodified out of that path is still id-equal.