When words are good and when words are bad

Paul Haahr haahr at macbeth.UUCP
Mon Jul 29 14:35:07 AEST 1985


Jon Mauney (mcnc!ncsu!mauney) writes in <2903 at ncsu.UUCP>:

> If symbols are so great, why not do away with keywords entirely?  We could
> use <- for "goto", @-> for "if", >< for "while", and [->] for "switch".
> Wouldn't that make programs a lot easier to read?

Dijkstra et. al. use the guarded command syntax with extremely few keywords,
(i.e. do od if fi proc skip...) and heavy use of symbols to produce what
many people consider readable code.

I do work in lisp and certainly don't find (plus a b) more readable than
"a + b", or (setq a b) easier to understand than a = b or a := b.  The notation
of (algol|fortran)-like languages certainly parallels more closely mathematics,
which is how most people are taught ideas like multiplication.

Control flow is something people generally first learn in computer science,
so there is really no argument saying that we should steal from some other
field a better notation.  Use of keywords has been around for a while, but
that seems to be only because that's the way things were done way back when.

Certainly the notation you suggest is (intentionally) awful, but writing
-> (or => or something) makes sense.  Even in Ada (tm - DoD/AJPO), the most
verbose of languages (not that this is necessarily bad, just an observation)
the design team made the choice of use the "when green =>" rather than
"when blue do" notation.  That wasn't thought to decrease readability.

Besides, what are words but symbols?  They just happen to be symbols made
up of symbols in a specific alphabet that have a meaning some arbitrary
language (in this case English) that a lot of people have at least a
passing familiarity with.  One could argue that fewer keywords and more
symbols in a programming language would lead to a more international
(at least spoken language independent) style of programming.

I am not arguing that the use of symbols is inherently better.  I am arguing
that carefully picked out symbols can lead to readable program structures.
For expressions.  For control flow.  And for data types (note that I find
C's notation worse than Pascal's for data types, and find this the part of
C I like least, but this is the specific notation used and the use of notation
in general).

To quote the 4.2 bsd distribution of fortune:
	Re graphics:  A picture is worth 10K words -- but only those to
	describe the picture.  Hardly any sets of 10K words can be adequately
	described with pictures.

Now algorithms aren't pictures.  Or words.  And a combination of words and
pictures together provide the description of an algorithm.  I find that more
symbols help describe these ideas.  Obviously there are different opinions.
-- 
				Paul Haahr
				..!princeton!macbeth!haahr



More information about the Comp.lang.c mailing list