Re:Using Rust at a startup: A cautionary tale
by masklinn on Saturday December 03, 2022 @12:09PM
(#33845018)
> 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
Re:Using Rust at a startup: A cautionary tale
by lolinder on Saturday December 03, 2022 @12:31PM
(#33845254)
True, 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.
Re:Using Rust at a startup: A cautionary tale
by zozbot234 on Saturday December 03, 2022 @12:38PM
(#33845317)
You 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 are way more efficient than GC. It's even simpler to use .clone() in order to effectively do away with any requirement for linearity.
Re:Using Rust at a startup: A cautionary tale
by steveklabnik on Saturday December 03, 2022 @05:53PM
(#33848335)
(Cell<T> doesn’t actually do runtime checking)
Re:Using Rust at a startup: A cautionary tale
by zozbot234 on Saturday December 03, 2022 @12:05PM
(#33844977)
Green threads have been totally superseded by current async support in Rust. That's why they're no longer part of the language itself.
Re:Using Rust at a startup: A cautionary tale
by masklinn on Saturday December 03, 2022 @12:13PM
(#33845064)
Technically green threads were removed when rust was moved “down the stack” back before 1.0: green threads would mean requiring a runtime (scheduler & al) which is problematic when targeting foundational libraries and embedded programming, it makes integrating with other systems a lot harder.
Async being opt-in means the people who don’t need it can avoid it, though it’s not always great when e.g. the premier HTTP client of the ecosystem provides a “blocking” interface which iirc just starts a runtime and delegates to the async interface.
I think OP doesn't understand that runtime features like GC and green threads have a cost, and Rust is designed around a making it safe to avoid that cost. Most of Rust's features don't make sense in the context of a managed runtime—what you would be left with is basically a subset of OCaml with C-style syntax and optional mutability.