C Programming Style -- New thought ("writing code")

John Woods john at frog.UUCP
Fri Jul 26 03:35:19 AEST 1985


>>I find that one of the things that most affects my personal choice of
>>program-formatting style is the number of lines on the console I work at.
>>Most of my C coding is done sitting in front of old-style displays of 24 by
>>80 lines.  
> 
> I assume this means you "write code" directly at a terminal, using a text
> editor, instead of the "venerable, traditional" way of writing it on paper
> first, with a pencil (and a *large* eraser), and then entering the stuff
> aftwerwards.
> 
> General question: does anybody "write code" on paper first any more?
>
Yes.  I prefer to, because it matches the way I think better.  However, this
(I feel) *increases* my desire for terseness.  Additionally, once I have typed
something in, I am more comfortable staring at hardcopy that a terminal
screen.  But once again, the more that is packed onto the page READABLY, the
better I like the code (and remember, you can't run GREP(1) on paper (yet)).

As an example:  the recent BYTE article on the TRAVESTY program (a few months
back) included a PASCAL program with a doubly nested loop, which had to use
a logical variable to escape from the inner one (I believe that that required
a double test in the while).  I recoded it in C, and came up with half the
number of lines, SIMPLIFIED IT TO A SINGLE LOOP using "C ``tricks''", and
came up with what I felt was vastly more readable code:  the whole function
"fit in my mind" at once.

The PASCAL program was not necessarily badly written; it was probably textbook
quality (not saying much :-).  However, readability is in the eye, and the
mind, of the beholder.

Who would you rather listen to, someone who gives an hour-long speech in
the 1000-word Basic English subset, or someone who uses the full power of
English to eloquently say the same thing in 5 minutes (without using archaic
words not in use for 300 years, note)?


--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA



More information about the Comp.lang.c mailing list