4 ms·
I wonder what the performance of this is. While functional languages like Haskell are optimized for these kinds of data structures, I doubt Javascript runtimes
by hesselink 12y ago
I wonder what the performance of this is. While functional languages like Haskell are optimized for these kinds of data structures, I doubt Javascript runtimes currently are. We've been bitten before by writing code in too much of a functional style and getting terrible performance, so benchmarks would be really useful before we'd start to use this.
- shanemhansen 12y agoI agree that benchmarks are the final arbiter, but javascript engines are pretty well optimized for handling garbage. So if you're going to be making garbage, javascript isn't a bad language to do it in, and immutable data structure algorithmic performance isn't going to change in js.
- Sonata 12y agoHaskell and Clojure both use structure-sharing data structures, which allow immutability without the cost of copying the entire structure whenever you want to make an update. They also use laziness to improve the performance of their data structures. If you want an implementation of these ideas in JS, Immutable.js [0] or Mori [1] are the leading libraries. seamless-immutable doesn't use these techniques, so it probably wouldn't perform well on large data sets. The benefit of it is that the immutable objects can be used as drop-in replacements for their native JS equivalents in some situations. Full disclosure: I've contributed to Immutable.js [0] https://github.com/facebook/immutable-js https://github.com/facebook/immutable-js [1] https://github.com/swannodette/mori https://github.com/swannodette/mori