Path: utzoo!dciem!nrcaer!sce!msn034!kim From: kim@msn034.misemi (Kim Letkeman) Newsgroups: comp.lang.c Subject: Re: C style (was: Efficient coding considered harmful?) Message-ID: <416@msn034.misemi> Date: 19 Nov 88 21:57:49 GMT Article-I.D.: msn034.416 References: <3105@hubcap.UUCP> <34112@XAIT.XEROX.COM> <1700@dataio.Data-IO.COM> <8864@smoke.BRL.MIL> Organization: MITEL Corporation, Kanata, Ontario, Canada. Lines: 32 In article <8864@smoke.BRL.MIL>, gwyn@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