3 ms·
rsc should really know better, he has been around long enough. C and C++ have as a basic design rationale "as close to machine performance as possible"
by grandinj 3y ago
rsc should really know better, he has been around long enough.
C and C++ have as a basic design rationale
"as close to machine performance as possible"
"don't pay for what you don't use"
"don't break backwards compatibility"
The last one is what is what is responsible for most of the issues. It would be nice to fix stuff like UB, but the reason that C/C++ is so popular and still alive is precisely because it does care more about compatibility than fixing stuff likethat.
Breaking existing code is extremely uncool for long-lived codebases.
- agwa 3y agoUndefined behavior permits backwards compatibility to be broken, because when a compiler adds a new optimization that exploits UB, existing programs can change behavior, breaking code that previously worked. The blog post cites infinite loops as an example. Thus, eliminating UB would improve backwards compatibility.
- layer8 3y agoCompatibility is defined in terms of a contract between program and language implementation. If the program violates the contract by containing UB, then compatibility does not apply. Taking your argument, compilers couldn’t even add any benign optimization without breaking compatibility, because that would change the runtime of the affected code.
- agwa 3y ago> Compatibility is defined in terms of a contract between program and language implementation. If the program violates the contract by containing UB, then compatibility does not apply. Indeed, furthering my point that having UB in a language undermines backwards compatibility. > Taking your argument, compilers couldn’t even add any benign optimization without breaking compatibility, because that would change the runtime of the affected code. That does not follow from what I said.
- layer8 3y agoThe point is, you have to define compatibility with regards to what. Otherwise nothing can ever change. The purpose of the C standard is to provide that reference point, via its definition of what constitutes a conforming program and a conforming language implementation. You only get compatibility problems when you step out of that scope.