3 ms·
Does Perceus differ substantially from using https://lib.rs/crates/im https://lib.rs/crates/im and writing code which looks identical to imperative code, but cl
by nyanpasu64 4y ago
Does Perceus differ substantially from using https://lib.rs/crates/im https://lib.rs/crates/im and writing code which looks identical to imperative code, but cloning is faster and mutations are slower (and copy internal structures as necessary)?
- miloignis 4y agoIt does the same mutate-if-unique optimization as im, but it does so automatically and more broadly as a part of its optimized reference counting. Perceus can go beyond what im can do by re-using allocations between static types - one of their examples involves doing a tree traversal with O(1) extra space by using a zipper which gets optimized by Perceus into a Morris traversal - and the programmer doesn't have to do anything special to get the benefit! (of course, writing code in such a way that you know it will be optimized has performance benefits if you do know how it works) This sets up this wonderful situation where you can write easier-to-maintain and easier-to-verify-correct algorithms that get optimized into very efficient versions that would be hard to write by hand even in a mutable/imperative language. Their papers and online docs are very good, I highly recommend them for more information!