News for hackers. Stuff that matters.
Re:Programming Language Rankings: January 2019 by jandrewrogers on Saturday March 23, 2019 @11:35AM (#19470862)
I have many years of experience with large-scale C++ projects at multiple companies, and have written >100kLoC of modern C++ personally. I've seen thousands of bugs come and go. Memory safety bugs are vanishingly rare in the code bases I've worked on, and in all those years the handful that I recall were created by people new to C++ (usually cross-trained Java programmers). It is difficult to create memory safety bugs in idiomatic modern C++, and achieving this has no meaningful overhead. Memory safety is important but Rust proponents have constructed a bit of a straw man with respect to modern C++. Use that argument against C or classic C++, where it has more relevance.

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.

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.)