Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!pacbell.com!pacbell!barn!everexn!grenada!christmas!rtm From: rtm@christmas.UUCP (Richard Minner) Newsgroups: comp.lang.c Subject: Re: a style question Summary: doesn't anyone line things up? Message-ID: <13@christmas.UUCP> Date: 25 Oct 90 03:21:01 GMT References: <8660@ncar.ucar.edu> <2039@excelan.COM> <443@mole-end.UUCP> <1990Oct23.160116.10299@athena.mit.edu> Reply-To: rtm@island.uu.net (Richard Minner) Organization: Island Graphics, Sacramento, California Lines: 53 In article <1990Oct23.160116.10299@athena.mit.edu> tada@athena.mit.edu (Michael J Zehr) writes: >[stuff about printer makes i's and 1's look similar] >This happened to a friend once: >int a[height][width]; >for(i=0; i for(j=0; j v = (a[i-1][j-1] + a[i][j-1] + a[i-1][j+i] + > a[i-1][j] + a[i][j] + a[i-1][j+1] + > a[i-1][j+1] + a[i][j-1] + a[i-1][j+1])/9; > >y'all see the mistake at the end of line the 4th line immediately, >right? This brings up something that still amazes me. I'd have written the broken portion above as: v = (a[i-1][j-1] + a[i][j-1] + a[i-1][j+i] + a[i-1][j ] + a[i][j ] + a[i-1][j+1] + a[i-1][j+1] + a[i][j-1] + a[i-1][j+1])/9; in which case I would indeed immediately see all that is wrong with it. (Lot's, it appears, even ignoring that a[i-1] doesn't exists for i == 0, etc. BTW, actually I would have written it right the first time.) (As to printers that make i's and 1's look alike, all I can say is stop using them ;-) Who prints code anyway? >-) Hmmm, I've seen code that starts its indices at `j' instead of `i'. Maybe that's why... but I digress.) My question is why is so little of the code I've seen `neat' in appearance? I have this anal tendency to line things up as much as possible, and otherwise neaten the code. To me, it makes similarities and differences stand out so much better. Sometimes I'll even try a few different layouts and pick the one that seems clearest (sick, I know). I've even spotted errors in foreign code after realigning it to get a better look. I really am just curious why this seems to be so uncommon. First, is it really uncommon, or have I just missed this big pool of neat code out there? Or do I just have a lower `complexity/tangle threshold' than most people? Is it just not worth the trouble? Is vi too hard to use?-) Is it because `indent' and the like just mess it all up anyway? Do others actually find aligned code *harder* to read? (I suppose it's possible.) What could it be? I remember a story/joke about an APL programmer who said that the reason he liked APL was that with most other languages his (non-technical) manager could make some sense of the code, and so didn't appreciate it as much, but with APL it was totally incomprehensible and so the manager was in awe, and of course paid more. Maybe that's it. Enough already. -- Richard Minner || {uunet,sun,well}!island!rtm (916) 736-1323 || || Island Graphics Corporation Sacramento, CA ||