6 ms·
I think the thing is users of C compilers generally care about raw performance much much less than compiler maintainers who are universally using C++. Compiler
by Gibbon1 5y ago
I think the thing is users of C compilers generally care about raw performance much much less than compiler maintainers who are universally using C++.
Compiler writers are stuck in a trap. C++ compilation model is broken. Which makes compiling C++ programs very slow. Which means compiler writers care a lot about how fast compilers are. So they desperately add more optimizations to speed up the compiler program. But which adds more work to the process of compiling a program.
Most of the other users, especially C programmers don't care about speed nearly as much. Notably because while the compilation model for C is also broken, it's not nearly so. So their programs compile in a few seconds, not minutes to hours.
- MauranKilom 5y agoI submit that this viewpoint is very mistaken. If it were true, "users of C compilers" would just compile with optimizations off and there would not be any problem. Evidently, "most of the other users" do care about performance. Unsurprisingly, I might add.
- Gibbon1 5y agoIf I am mistaken why do most programmers prefer slower to vastly slower languages such as JavaScript, Java, C#, Go, Python, PHP, or Lua? If they really thought that speed was the most important thing wouldn't that abandon those languages for C++. Explain yourself.
- rowanG077 5y agoIt's the opposite. People use C and C++ because of their speed. If you don't need the speed then there is little reason to use C or C++. This makes these optimization absolutely vital for C and C++.
- dmz73 5y agoI think a lot (not all) of people will use C and C++ because they need good performance, compile time checks, portability across OS/CPU architectures and reasonable memory usage. Most of the people who use C and C++ are average programmers who think their programs will do exactly what they wrote in the source code. The issue is that optimizations are required to get expected performance but some optimizations will result in programs not doing what user specified in the source code. Compiler should offer a clear split between "safe" optimizations that will not change what source code says and "unsafe" optimizations that will do their best to create fastest code. I don't use C or C++ very often and I don't know how optimizations are currently structured but if a lot of people are constantly caught unaware of what optimizations are in use and how they affect the output then this is obviously either a documentation issue or compiler interface issue - both of these are up to compiler writers to fix.
- rowanG077 5y agoWhat the source code says it does is exactly specced in the language standard. If the compiler changes this then that's a compiler bug. What you really meant to say is what people assume source code does, not what it says it does.
- josephcsible 5y agoDistinguish programs not doing what the user specified in the source code from programs not doing what the user incorrectly thought they specified in the source code.
- benibela 5y agoI have always used Pascal for those reasons, and fast compilation speed FreePascal only does safe optimizations. (unless it has bugs where it does work at all)
- MauranKilom 5y ago> why do most programmers prefer slower to vastly slower languages such as JavaScript, Java, C#, Go, Python, PHP, or Lua? So your argument is "people not using C don't care about the speed of C"? What is this supposed to be proving?
- jhgb 5y agoDoesn't Wirth actually believe the same thing about compilers? Specifically the part about > compiler writers care a lot about how fast compilers are. So they desperately add more optimizations to speed up the compiler program. But which adds more work to the process of compiling a program.
- josephcsible 5y agoAre you mixing up caring about compilation speed with caring about the speed the program runs after being compiled?
- umanwizard 5y agoIf you work on a (self-hosting) compiler, those are the same.
- josephcsible 5y agoNot really. Compilers are supposed to be fast at compiling things other than themselves.
- jhgb 5y agoBut self-compilation speed is a common benchmark for this, because compilers themselves are rich programs that exercise all parts of the compiler and the compilation speed of which can be measured.
- Gibbon1 5y agoYes if you write C++ compilers in C++ they are the same. Compiler writers are stuck. The more optimizations they add. The more work the compiler has to do. And the slower it runs. Defeating the purpose of those optimizations. If you write other types of programs the compilers speed and your programs speed aren't the same at all. People that write other types of programs care more how fast the compiler is and less how fast their programs run. People that write programs that process entrusted data care vastly more about no surprises than they care about speed. Even more so, in modern code bases the hot sections are very small parts of the total code base. For 99% of the code, CPU speed doesn't matter. The whole thing is made worse because of the disconnect between modern CPU's and machine implemented by C++.
- MauranKilom 5y ago> If you write other types of programs the compilers speed and your programs speed aren't the same at all. People that write other types of programs care more how fast the compiler is and less how fast their programs run. People that write programs that process entrusted data care vastly more about no surprises than they care about speed. Even more so, in modern code bases the hot sections are very small parts of the total code base. For 99% of the code, CPU speed doesn't matter. Literally everything you ask for here is fulfilled by not turning on compiler optimizations. That's the default. I don't understand what your complaint is. And since nobody stated it plainly to you yet: This whole world view is completely bogus. Entire branches of the industry require C++ compilers that produce the fastest possible code (to name a few: Games, HFT, image processing). I don't know how you convinced yourself that compiler writers are the only consumers of compiler optimizations, but it's dead wrong. I don't claim your experience or what tradeoffs you seek in a compiler are wrong, but they are extremely far from universal.