Re:Programming Language Rankings: January 2019
by pcwalton on Saturday March 23, 2019 @12:38PM
(#19471139)
I also have many years of experience with large-scale C++, and my experience is very different from yours. The difference, I suspect, is that browsers are actively attacked, via fuzzers and so forth. When you have contests like Pwn2Own targeting you, it's very eye-opening how many memory safety bugs you are shipping, even in fancy modern C++.
(I also disagree that modern C++ is safer than classic C++. Modern C++ adds more invisible ways to get use-after-free, which is pernicious.)
At the same time, modern C++ also has advanced and valuable safety features that Rust does not have e.g. the enormous amount of compile-time verification and complex type construction that is possible. I find these to be far more valuable because the kind of bugs these catch are more common in practice. None of this is automatic but it is trivially enforceable as coding style, and many companies do.
The idea that C++ code bases are necessarily littered with memory safety bugs is nonsense. For people that have been writing this kind of code for a long time, avoiding those bugs is largely automatic and effortless. And you don't have to do violence to your data structures to achieve it. I can see an argument for someone coming into C++ from a language like Java but for experienced C++ programmers the value is dubious in practice.
There may be compelling technical reasons to use Rust over modern C++ but you'll have to do better than automatic memory safety, particularly given the safety and capabilities that would be sacrificed.