3 ms·
I have another falsehood: most programmers believe that people working with C/C++ are constantly battling against UB all day long, five days a week, and that th
by scoutt 4y ago
I have another falsehood: most programmers believe that people working with C/C++ are constantly battling against UB all day long, five days a week, and that they are irresponsable and careless. That they should live in fear and terror, because "unsafe" is around the corner, and that their programs are not mathematically proven and that they might containt an explotaible bug because, you know, every other C/C++ program opens a socket to the internet or is a "sudo" kind of tool.
- mattarm 4y agoAn automobile recall is a good analogy here. Most people driving cars with an active recall are unaffected by the problem the recall is supposed to address. They can drive on blissfully unaware that something could go wrong. They might even enthusiastically recommend that others purchase the car they drive. For a few people, they'll experience a failure, possibly a dangerous one. And this is the root of the problem. The fundamental concept of using a language prone to UB exposes all programs to a small risk. In isolation, the risk is small. In aggregate, the problem is real.
- scoutt 4y agoThe same applies to vaccines and medicine drugs. Should we stop giving them to people? "For a few people, they'll experience a failure, possibly a dangerous one.". Should we try our best to minimize the risks? Absolutely. But we are talking programs here. We shouldn't measure every program with the same ruler. Not all programs need to be MISRA compliant when they don't need to. My Reddit app crashes several times a day, and I guess there is no immediate danger.
- Quekid5 4y agoThere are no viable alternatives to vaccines and medicine in general (ones that actually work, that is). There are alternatives to C -- for most cases. > My Reddit app crashes several times a day, and I guess there is no immediate danger. That's because your app is heavily sandboxed and probably (on Android, at least) running in a VM which enforces memory safety and isolation from other apps. If each crash had, say, a 1% likelihood of eating a large portion of your data (or leaking pictures or whatever) you'd probably care a lot more about it. The problem highlighted by the parent poster is that all these little risks add up and often end up being catastrophic (e.g. heartbleed) because so much of what we run is interconnected via the network (or just data in files).
- morelisp 4y agoIt can be true that most programmers working in C or C++ are spending most of their time solving real problems that are still most effectively solved by C or C++, and at the same time, that even the absolute top C and C++ programmers regularly misapprehend UB itself or whether their own code contains UB in a way that causes a serious issue for the program.