C style (was: Efficient coding considered harmful?)

Kim Letkeman kim at msn034.misemi
Sun Nov 20 07:57:49 AEST 1988


In article <8864 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:

[ much verbiage removed for brevity ...]

> 
> Judging by the errors I have seen in literally millions of lines of C
> code, the C programmer who thinks primarily in terms of bits is probably
> introducing scads of present and future bugs into his code.
> 
> >You have any idea how long a multiply takes on most architectures?
> 
> Not normally long enough to worry about.
> 
> One should micro-optimize only those sections of code that need it,
> when it is clear that the tradeoff against maintainability is worthwhile.
> To do this for all source code would be making a poor long-term tradeoff.

No question about it. Too many people write poorly structured, unclear
(add as many unpleasant labels as you like) code for no better reason than
a perceived need to write the fastest code on the planet. While I realize
that garden-variety 4.77 mhz machines really appreciate fast code (I own
one myself), micro-optimizing a whole program is overkill to say the least.

One only need read Software Tools and Elements of Programming Style to 
realize that for most programs, the vast majority of the code will have
almost no affect on the overall performance of the program (providing of
course that there are no gross algorithmic blunders.) I have found that 
optimization efforts that focused on better algorithms payed off in order 
of magnitude increases in performance while optimizing a single routine 
usually gives back some fraction of 1 percent ...

Kim



More information about the Comp.lang.c mailing list