5 ms·
> The absolute danger of a space shuttle is much greater than a bike. But the absolute danger of C++ versus C is… equivalent. Okay, let's pretend, for the sake
by lelanthran 28d ago
> The absolute danger of a space shuttle is much greater than a bike. But the absolute danger of C++ versus C is… equivalent.
Okay, let's pretend, for the sake of this conversation, that the absolute danger in the event of failure for both the bike and the space shuttle are exactly the same.
My analogy still holds in this hypothetical case: the odds of a failure operating a space shuttle is much much larger than the odds of a failure when operating a bicycle. Using C++ is a much larger cognitive load than using C, same as launching and piloting a space shuttle is a much larger cognitive load than riding a bicycle.
It doesn't matter that the space shuttle has hundreds, if not thousands, of safeguards built into both the vehicle and the process, while the bicycle doesn't have so much as a seatbelt; the bicycle is still safer to operate because of the lower cognitive burden.
There are simply more rules to remember in C++ to ensure that you don't get exploited than in C. Ask the average working C++ devs about the danger between virtual vs concrete destructors in derived classes and half of them won't know what you mean. Ask about putting objects into a std vector, and maybe half of them will remember the surprise they felt when it first broke (because it worked until that point).
C++ provides global ways of avoiding footguns, but those global ways are not easily inspectable in the local scope. The problem is the sheer number of C++ footguns is simply overwhelming[1]. There's a handful of C footguns to commit to memory (signed overflows, used-after-free, etc), and they're all visually inspectable in the local scope.
When I need to a language better than C, I don't reach for C++.
------------------
[1] Even world-renowned C++ superstars with decades under their belt can't come back to it after a mere 2 years. You don't see that with C.
- chris_wot 26d ago[dead]