3 ms·
> I have little to no idea what a three-line loop will be compiled as, but bloat would be my guess. This is unfortunately too often true. Some compilers are tu
by cliffbean 14y ago
> I have little to no idea what a three-line loop will be compiled as, but bloat would be my guess.
This is unfortunately too often true. Some compilers are tuned too much for looking good on artificial benchmarks, in which turning 3-line loops into thousands of instructions sometimes helps, even if it hurts on most real-world code.
> And if I don't want the compiler to do this, I have no idea how to stop this behavior, nor do I want to invest in the specific knowledge of the nuances any particular compiler.
The -O0 option, or its equivalent, is pretty easy to find in many compilers. If you're happy with the performance of your code without all those fancy techniques being applied, feel free to use it. Most people aren't ;-).
> P.S. Oh, and by the way if I really wasn't using half of the code I wrote, I would throw the source code away.
Only if you were aware of it ;-). I wish that compilers would focus a little more on helping me make my code better, rather than so much on magically making things better under the covers.
- JasonFruit 14y agoIf you want your compiler to do more to help you improve your source, you might like Go, which offers a lot of (sometimes unwelcome) mandatory suggestions that force you to do the right thing even when you don't want to. (Ada and Pascal do the same thing according to a very different philosophy.)
- rthomas6 14y agoI have come to love the strong typing of VHDL (very similar to Ada but for hardware design). After using it for a while, in my uninformed opinion, I think it can drastically reduce bugs because it assumes nothing and makes the programmer define exactly what they mean.
- ncallaway 14y agoEven better for him, -O0 is the default (for most compiler's I've worked with). You need to opt-in to optimizations most of the time.