News for hackers. Stuff that matters.
Re:Zig VP of community comments on Rust by suremarc on Saturday September 10, 2022 @07:41PM (#32795464)
> It has shown that GC vs manual memory management has a third option.

C++ had shown this long before Rust.

Re:Zig VP of community comments on Rust by whimsicalism on Saturday September 10, 2022 @09:51PM (#32796159)
C++, despite RAII, is still manual memory management IMO
Re:Zig VP of community comments on Rust by suremarc on Saturday September 10, 2022 @10:29PM (#32796342)
How is memory management with Vec and Box in Rust any different from std::vector and std::unique_ptr in C++?
Re:Zig VP of community comments on Rust by chlorion on Sunday September 11, 2022 @12:59AM (#32796954)
They aren't :)

The main thing I guess is dealing with C APIs in C++. You do have to use C APIs in Rust as well though, but maybe dealing directly with plain C APIs is less common because of how annoying it is. The only way to avoid that pain is to make a Wrapper library that exposes a more idiomatic and possibly "safe" interface. C++ can wrap C APIs just as well though.

I agree with you though, C++ has been doing RAII for a while and I'm not sure why people seem to think Rust invented it. Idiomatic C++ APIs and code are just as "automatic" as Rust for the most part!

Re:Zig VP of community comments on Rust by tommiegannert on Sunday September 11, 2022 @02:42AM (#32797369)
C++ doesn't have the borrow checker of Rust. Isn't that what made Rust famous?

(Your literal question is a straw man: no, those aren't different, but Rust offers more.)

Re:Zig VP of community comments on Rust by suremarc on Sunday September 11, 2022 @03:46AM (#32797622)
I don’t really understand what the borrow checker has to do with the automatic/manual memory management dichotomy.
Re:Zig VP of community comments on Rust by pornel on Sunday September 11, 2022 @01:20PM (#32801430)
Even though ownership and borrowing are theoretically orthogonal, they're both needed to make a complete safe system (the context was about managing memory for safety, not merely having a syntax sugar for malloc/free.)

Unique ownership prevents leaks and double-free, and borrow checking prevents use-after-free. Borrowing is necessary to temporarily relax the exclusivity of uniquely-owned objects and access their interior. Access to interior of a unique_ptr (and shared_ptr) decays it to a reference or a bare pointer that is not managed by the smart pointer any more, and can be left dangling. Borrow checker eliminates the manual "be careful not to leave dangling pointers" part.