News for hackers. Stuff that matters.
Re:Assorted Thoughts on Zig and Rust by sacado2 on Tuesday October 20, 2020 @08:48AM (#24836660)
> I think enabling a language to be garbage collected in general, while making a borrow checker opt in for special, time critical functions is the best of both worlds.

Put everything you don't want to manage into Rcs, RefCells, Boxes and the like, and you'll more or less feel like you're using a (verbose) GCed language (with a loss of performance and safety as a natural consequence).

> I enjoy Rust and have been writing it for quite some time. However, I feel like server side languages still have a long way to go. Client-side languages in comparison have been only growing better

The fact you call them "server-side language" is a strong bias. Not everything is a client/server app.

Re:Assorted Thoughts on Zig and Rust by j-krieger on Tuesday October 20, 2020 @11:06AM (#24838175)
RefCells and Boxes just throw the same errors at runtime instead of compile time.
Re:Assorted Thoughts on Zig and Rust by estebank on Tuesday October 20, 2020 @12:53PM (#24839645)
RefCell is runtime "borrow checking" where a panic is thrown if the object is already mutably borrowed. Depending on your use case you might not even care about this behavior because you have other invariants that ensure that you're only borrowing mutably once, you just can't encode it in the type system. Otherwise, you would combine it with Rc[1]: Rc<RefCell<T>>.

Box, on the other hand, doesn't have any runtime cost. In fact, it's runtime cost is the same as a borrow: both & and Box<T> are just plain pointers, with the extra benefit of having compile time lifetime checking.

[1] https://doc.rust-lang.org/book/ch15-05-interior-mutability.h...

Re:Assorted Thoughts on Zig and Rust by steveklabnik on Tuesday October 20, 2020 @11:24AM (#24838421)
(RefCell yes, but box no)
Re:Assorted Thoughts on Zig and Rust by j-krieger on Saturday October 24, 2020 @06:24PM (#24882380)
Woops, I guess I meant RC's and RefCells.