News for hackers. Stuff that matters.
Re:Fish (shell) porting to Rust from C++ by plasticeagle on Tuesday January 31, 2023 @03:45AM (#34592810)
Well, I don't know about borrow checkers, but scoped memory was added to C++ over a decade ago. In fact, I led the charge to remove every single new and delete from our codebase, and cause add it to the list of things disallowed by the static analysis tools.

Today, I wouldn't use new or delete in any C++ program for any reason. Segfaults and null pointers have become extremely rare.

Re:Fish (shell) porting to Rust from C++ by John23832 on Tuesday January 31, 2023 @04:30AM (#34593129)
I appreciate that RAII is in C++ as well. RAII is an addition to C++. You can write valid C++ with memory leaks all over the place. This is the nature of being a superset of C. In Rust, there is no other way (outside of using unsafe). It is a language based around compile time memory safety. Segfaults and null pointers aren't extremely rare, they're extremely rare in modern C++ (which is a subset of all C++)

The borrow checker validates references as they are passed throughout your program. You can have either (many immutable references || one mutable references). This may seem simple but is key to the memory safety ideas. The usages of references are validated. Move semantics are checked at compile time.

Re:Fish (shell) porting to Rust from C++ by rami3l on Tuesday January 31, 2023 @08:14AM (#34594624)
However the borrow checker is not only about new/delete, it also prevents other forms of reference invalidations (e.g. when holding a reference to a vector element while appending to the vector, that reference can become invalid when the vector gets resized).