3 ms·
> Most of Rust's features don't make sense in the context of a managed runtime I don’t think that’s entirely true actually (which is why linearity is explored
by masklinn 4y ago
> Most of Rust's features don't make sense in the context of a managed runtime
I don’t think that’s entirely true actually (which is why linearity is explored in languages like haskell).
For instance Go makes it easier to trigger data races, which undermine memory safety. This is a managed langage “built for concurrency” where using concurrency means memory safety is at risk.
And that’s not recent news, Russ Cox himself wrote about it back in 2010: https://research.swtch.com/gorace https://research.swtch.com/gorace
- lolinder 4y agoTrue, but linearity/affine types applied carefully in the context of a managed runtime would look quite different from Rust's borrow checker. The reason why Rust's borrow checker is so infamous is because Rust has to prove everything at compile time. Bringing affine types to a GC language would most likely involve making them opt-in (or only triggered in concurrent situations), while making linearity optional in Rust would undermine its foundations.
- zozbot234 4y agoYou can opt into runtime checking in Rust via interior mutability. Cell<>, RefCell<>, Rc<>, Arc<>, Mutex<>, Rwlock<> are constructs that involve varying levels of runtime checking - most of these will be way more efficient than GC. It's even simpler to use .clone() in order to effectively do away with any requirement for linearity.
- steveklabnik 4y ago(Cell<T> doesn’t actually do runtime checking)