News for hackers. Stuff that matters.
Re:Immutable.rs: immutable data structures for Rust by taeric on Friday April 06, 2018 @05:12PM (#16777498)
Seems misguided, though. Specifically, this has the implicit claim that the shared structures will be faster than the alternative. The whole "is both cheap and safe." However, Rust uses other mechanisms to provide the safety, such that it may be "cheaper," but only compared to copying the full data structure. It will not be cheaper than just modifying in place.

The question, then, is how often is that strategy truly idiomatic and a net win in Rust?

Re:Immutable.rs: immutable data structures for Rust by steveklabnik on Friday April 06, 2018 @05:14PM (#16777511)
We had a talk at RustConf previously about the Xi editor; it uses an immutable data structure to handle text. It's a video but the author lays out the details here: https://www.youtube.com/watch?v=SKtQgFBRUvQ

They make an interesting argument about how Rust makes it easier and nicer to write these kinds of structures.

It's still an area of exploration in Rust generally though; I wouldn't say immutable data structures are idiomatic, but that's also just because we haven't had a ton of easy ones to use, so nobody uses them. So we'll see!

Re:Immutable.rs: immutable data structures for Rust by raphlinus on Friday April 06, 2018 @05:40PM (#16777694)
Thanks for the shout-out. You can also read the docs[0] about the rope data structure (the release is a bit old, if you're really curious git master is better).

I admit this is a fairly specialized use case, for most things xi uses mutability in a controlled way.

[0] https://docs.rs/xi-rope/0.2.0/xi_rope/tree/index.html

Re:Immutable.rs: immutable data structures for Rust by taeric on Friday April 06, 2018 @05:24PM (#16777589)
I saw downthread a link to someone talking about how you can already treat the standard collections as values. Has a good argument for how it can be beneficial to keep the same interface regardless. Has a good concession that there are definitely use cases where persistent collections make sense. I'd imagine they are not as common as one could expect. (I grant they are also likely more common than I expect. :) )
Re:Immutable.rs: immutable data structures for Rust by cryptonector on Friday April 06, 2018 @06:05PM (#16777887)
With an immutable data structure the only synchronization cost is that of atomic reference count increment/decrement, but it feels like you're mutating shared objects, so the API is very easy to use.

For an example API I'm familiar with, see https://github.com/stedolan/jq/wiki/C-API:-jv