3 ms·
I'm not saying compilers shouldn't optimize, they just shouldn't try to be clever. Some things can be expected to be done by most any compiler, many things are
by galacticpony 10y ago
I'm not saying compilers shouldn't optimize, they just shouldn't try to be clever. Some things can be expected to be done by most any compiler, many things are extremely compiler-specific and only work under very specific circumstances.
- pcwalton 10y agoI agree that there is a line beyond which you shouldn't expect compilers to optimize. But "being clever" is responsible for lots of seemingly-simple optimizations. If you want something to blame, blame the C language for making program transformations hard due to unrestricted aliasing and so forth. Don't blame compiler authors for responding to the demands of their users.
- galacticpony 10y agoMany users don't want "clever" optimizations and compiler authors often implement things that nobody would ever ask for, because it has no real-world benefit. See: https://www.theregister.co.uk/2015/11/01/linus_torvalds_fires_off_angry_compilermasturbation_rant/ https://www.theregister.co.uk/2015/11/01/linus_torvalds_fire... If we had an hour to discuss which optimizations are or are not "clever" in the derogatory sense, maybe we would agree on almost everything. Alas, I've spent enough time on this thread. Good day!
- sqeaky 10y agoTaken to its logical conclusion this is an argument that things should never change and never try to get better. Clearly that is not what you mean and is not a good thing. Perhaps optimizing compilers put you outside of your comfort zone because you think they force you to learn and keep up to date. You can do that or you can stick to writing idiomatic code that uses the std library for a given compiler. Doing just this tends to produce extremely good results. I often outdo others near just with this when they are dropping to assembly or doing silly workarounds because they know something is slow. Profiling and timing are required to pick up the rest of the performance, and presuming otherwise is silly. No special knowledge of the machine or compiler is required, just a knowledge of when and how to optimize and when and how to write idiomatically.
- galacticpony 10y ago"Taken to its logical conclusion this is an argument that things should never change and never try to get better." No, it doesn't. "Clearly that is not what you mean and is not a good thing. Perhaps optimizing compilers put you outside of your comfort zone because you think they force you to learn and keep up to date." Perhaps you're an idiot.
- dang 10y agoPosting uncivilly will get you banned regardless of how wrong the other person was, so please don't comment like this.