|
|
|
|
|
by dbaupp
4293 days ago
|
|
There's more to memory-unsafety than raw pointers; all of these are problems even in the most modern C++ versions: - iterator invalidation
- dangling references
- buffer overruns
- use after move (and somewhat, use after free)
- general undefined behaviour (e.g. overlong shifts, signed integer overflow)
And there's more to memory safety than security critical applications. Rust means you spend a little more time fighting the compiler, but a lot less time fighting the debugger and a lot less time trying to reproduce heisenbugs caused by data races/undefined behaviour.Of course, the library/tool support is indisputably in C++'s favour. > if you're an idiot you can shoot yourself in the face If you're a human you will shoot yourself in the face. It just takes far too much brain power to write correct C++ always (a single mistake leads to brokenness), especially in a team where there can be implicit knowledge about how an API works/should work that may not be correctly transferred between people. |
|
On the other hand, it's somewhat ironic that you point to overlong shifts as a C++ problem when Rust has the exact same behavior. What does this function return?
Honestly, I loved the idea of Rust. I was sold a memory-safe C++, and that sounded awesome. But what I got instead was an ML with better low-level support; it felt like an enormous bait-and-switch, as nobody is interested in yet-another-functional-language.