News for hackers. Stuff that matters.
Re:Was Rust Worth It? by goku12 on Thursday October 26, 2023 @01:15AM (#38021859)
> I just wish Rust learning resources would be more upfront about this.

While beginner resources don't dwell too much upon cyclic references, they don't consider unsafe blocks as unusual. All the material I've seen say that there are certain domains where Rust's compile-time safety model simply won't work. What Rust allows you to do instead, is to limit the scope of unsafe blocks. However, the beginner material often won't give you too much details on how to analyze and decide on these compromises.

Anyway, compile-time safety checks (using borrow checker) and manual safety checks (using unsafe) aren't the only way to deal with safety. Cyclic references can be dealt with runtime safety checks too - like Rc and Weak.

Re:Was Rust Worth It? by mtsr on Thursday October 26, 2023 @02:50AM (#38022516)
> Cyclic references can be dealt with runtime safety checks too - like Rc and Weak.

Indeed. Starting out with code sprinkled with Rc, Weak, RefCell, etc is perfectly fine and performance will probably not be worse than in any other safe languages. And if you do this, Rust is pretty close to those languages in ease of use for what are otherwise complex topics in Rust.

A good reference for different approaches is Learn Rust With Entirely Too Many Linked Lists https://rust-unofficial.github.io/too-many-lists/

Re:Was Rust Worth It? by pncnmnp on Thursday October 26, 2023 @03:33AM (#38022803)
Also, take a look at GhostCell (https://plv.mpi-sws.org/rustbelt/ghostcell/ and https://www.youtube.com/watch?v=jIbubw86p0M). If anyone's used this in a project or production environment, I'd love to hear your firsthand experiences and insights.
Re:Was Rust Worth It? by pjmlp on Thursday October 26, 2023 @04:45AM (#38023248)
Except in those other languages the compiler types .clone() for me.
Re:Was Rust Worth It? by chalsprhebaodu on Thursday October 26, 2023 @07:14AM (#38024076)
Sometimes the compiler types clone for you even you don’t actually want it to.
Re:Was Rust Worth It? by pjmlp on Thursday October 26, 2023 @08:19AM (#38024549)
It is easier to tell it, "don't do it this time" than all the time.

It is no accident that while Val/Hylo, Chapel and Swift have taken inspiration from Rust, they have decided to not inflict the affine types directly into the language users, rather let the compiler do part of the work itself.

Re:Was Rust Worth It? by lumost on Friday October 27, 2023 @04:34PM (#38043549)
You still need a main owner in those patterns, that owner must be part of a DAG of owners - you cannot have cyclic ownership.