[comp.lang.misc] X11 bashing

gaynor@yoko.rutgers.edu (Silver) (04/28/91)

[What follows is a little jumbled because I'm in something of a rush.  Also, I
had to nuke the References: line, my modem ate it and I didn't feel like
regenerating it.  Since this discussion does not pertain to unix internals or
NeWS per se, I've directed followups to comp.lang.misc.]

> Sometimes white spaces are detrimental.

Hear, hear!, or Here, here!, or something!  White space can be cheap, but it's
rarely free.  Horizontal whitespace is typically cheaper than vertical
whitespace because almost all fonts are taller than they are wide.  That is,
there are more units of space available across the page than down.  The use of
whitespace must be weighed against the amount of code visible at one time,
because scrolling around is as much a detriment to readability as too much or
too little whitespace.  Code is only written once.  After that, it's a matter
of staring it down to find out what/how to modify it.  So, after the initial
heavy editing, give it a beautifying pass.  Eliminate a lot of unnecessary
whitespace.  Comments kind of fall in the same category.  Never comment in-line
that which is obvious or self-documenting.  It's a fairly common practice to
put atomic operations on seperate lines without even considering the operations
surrounding it.  I think it's better to put an single _semantic_ operation on a
single line if it's reasonably short.  I could spout more blather here, but
I'll hold off for now.

Here's a few things I usually do:

1.  Within expressions, I like to use whitespace to indicate operator
    precedence.  For example, I'll write "1 + 2*3" instead of "1 + 2 * 3", or
    "1  2 3 *  +" instead of "1 2 3 * +".

2.  Rarely will I devote an entire line to a mere grouping operator.  For
    instance, I'll take the left over the right any day.

        /foo                    /foo
          {add}                    {
        define                       add
                                   }
                                define

3.  An example of putting a semantic operation on a single line:

        ...
        /* `cat' F to stdout */
        {
          int c;
          while ((c = getc(F)) != EOF)
            putchar(c);
        }
        ...

    as opposed to

        ...
        /* `cat' F to stdout */
        {int c;  while  ((c = getc(F)) != EOF)  putchar(c);}
        ...

    I concede that less-compressed versions of the second form are easier to
    read.  But this is such a trivial operation that the lack of whitespace
    does not impair its readability enough to justify adding more.

Flamers: Try playing the devil's advocate before you send your followups.

Regards, [Ag] gaynor@paul.rutgers.edu