4 ms·
How does "undefined behavior" not qualify as "esoteric programming voodoo"?
by the_why_of_y 11y ago
How does "undefined behavior" not qualify as "esoteric programming voodoo"?
- xamuel 11y agoUB is not something that a competent programmer does intentionally. You shouldn't ever run into a situation where you'd tell your fellow programmer, "Hey, on line 300 here, you're doing UB, stop it", only for them to say "No, I'll do UB if I please". With C++ on the other hand, you could very well run into situations where you plead with your fellow programmer, e.g., "please stop overloading operators in this opaque and unmaintainable way", and then they tell you, "so what, that's our in-house style and it has official language blessing".
- pjmlp 11y agoSadly I am yet to work in an enterprise environment that fully understands the meaning of "competent programmer" in their hiring process, specially for offshore resources.
- the_why_of_y 11y agoC++ has roughly the same undefined behaviors as C, plus a bunch of additional ones for the C++ specific features. Also, you'd be surprised how many stubborn C programmers apparently think that mutable global variables are an excellent and convenient time-saver. (Not that C++ programmers do inherently any better here, cf. Singleton)
- cwzwarich 11y agoThe C spec also has a handy appendix listing all undefined behavior, which IIRC the C++ spec does not have.
- epsylon 11y agoYet even the most competent programmers will have UBs crawl into their code where they do not expect them. Sure, C has less pitfalls than C++ ; but it has its own as well. (see previous discussion on HN "What is C", John Regehr's blog, ...)