by sendilkumarn on 12/8/21, 10:59 AM with 14 comments
by gugagore on 12/9/21, 10:29 AM
Here is one library I've heard of https://immutable-js.com/ . I don't know of others.
by roenxi on 12/9/21, 10:11 AM
It was a bold decision with the potential to cause pain, but Clojure's vectors are great fun to work with. The "novel" basic data structures get out of the way and generally cause more joy than pain. It is part of a fundamental strategy enabling a strongly immutable style which really pays off when it works in concert with the rest of the language.
by tomp on 12/9/21, 11:44 AM
I did a quick survey of existing implementations in multiple languages and found all of them lacking. They are either overly complex, slow, or both. Even Clojure's vector, while being simple and very performant, is only usable as a stack, not as a queue, and therefore IMO inadequate as a "generic random-access array-like data structure" (akin to Python's list, i.e. "just use it don't worry about performance").
My version is about as fast as Clojure's vector, while implementing a "deque"-like interface. It's a bit more complex, but still significantly simpler than Scala's vectors (both Scala 2 and Scala 3). Cyclops (a Java-only persistent collection library) is so slow I didn't even bother finishing the benchmarks. I also compared my code to Rust's `im` (way more complex), C++'s `immer` (stack, not deque) and `immutable.js` (slower than ClojureScript).
I'll clean up the code and post it here.
by PMunch on 12/9/21, 12:30 PM