arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

more improvement? #73

Closed x4080 closed 8 years ago

x4080 commented 8 years ago

Hi, I read this article https://medium.com/outsystems-engineering/javascript-and-immutability-how-fast-is-fast-enough-27790cda4e9e#.igxhzts6g

Basically copy can be faster than using tree structure replacement like immutable, when some conditions met, maybe there can be an option to use copy or tree for even faster speed?

arqex commented 8 years ago

Hi @x4080

Thanks for this interesting article! Freezer.js doesn't use the HAT-trie algorithm, so it is already always coping all the not-modified attributes of a changing node.

This behavior makes freezer perform generally worse than immutable, but as the article says, there are some situations in that having to process all the trie algorithm is overkilling.

Not using the trie algorithm also makes freezer be much more lightweight and memory friendly than immutable

From my experience, even being slower than immutable, I have never had problems with the performance of freezer, and I have used it in environments where the store is constanty being updated ( svg-editor with live draging interactions ).

Anyways, it would be interesting try the algorithm with freezer, but sounds like a lot of work.

x4080 commented 8 years ago

cool, i prefer copying also because of small fields of record also. thanks