The Best of Creative Computing Volume 2 (published 1977)

Page 20 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails
This book is also available for the Kindle

About Computing (bugs in computer programs, debugging, algorithms)
by Geoffrey Chase

graphic of page

About Computing by Geoffrey Chase, OSB
Portsmouth Abbey School, RI

There's a famous "theorem" that runs something like this:

1. Any non-trivial program has at least one "bug".

2. (Corollary) Any program that works is trivial.

Computing-i.e., giving a set of instructions ("program") to a machine telling it
what to do and what paths to take if this rather than that happens, and when to
stop-is different from what most people seem to expect. To begin with, it
doesn't necessarily have anything much to do with numbers, arithmetic, or
algebra, though students of these subjects often use computers and usually (by
no means always) find programming easier than do people who haven't much math

Another odd feature is that it is not quite so much a matter of "right" or
"wrong" answers as one might think. Almost no one gets his program right the
first time he runs it, unless it's copied off a book or does nothing you
couldn't do better without the machine. And of those who do get the "right
answer"-i.e., a program that finally workssome will write programs that are
unnecessarily slow, use up too much of the machine's memory, and stretch an
accumulation of small errors into large ones [computers don't make mistakes but
they often generate error-figure that one out!]. Someone else may write a
program that is lean, taut, elegant, fast and accurate. Both have come up with
the "right answer", but the second program is obviously "righter" than the
first. Often it is also simpler, or simpler-looking, than the inferior program.

The hard part of computing is keeping your head clear. The easy part is what
looks hard, programming in some sort of language.

[image]l'd expected a little more documentation.

Some more "theorems", stated without proof:

3. Any fool can write a program no one else can understand. It takes
intelligence to write one that is clear and seems easy.

4. Our #3. fool will find, six weeks later, that even he can't figure lt out.

Write programs so someone else can read them. Use a few comments; make the order
of the program adhere as near as can be to the order in which one thinks about
the problem being solved.

5. Computers are dynamic-they "move" things. Many familiar expressions in math
and elsewhere are static, reflecting an unchanging truth but not giving much
hint of how to find or figure. So your job in most instances is to find some
sort of repeated process (they call computers "processors" sometimes) which will
get you what you want in a finite number of "moves" or steps.

Such a process is called an "algorithm". You often don't know, by the way, how
many moves or steps will be required; merely that there will be only a finite
number of them.

lt's not at all rare to write an "infinite program" by mistake. This can hang up
the processor and the programs of other users, who will be tempted perhaps to
hanging of another sort . . .

Example: Y = 5'x3 + 4'x2 + 3'x + 2 and X = (let's say) 1.2; how do we find the
value of "Y"?

"Static" method: multiply X times X times X times 5 and then ... all the way
down the line. A lot of work.

"Dynamic method": let Y = 5. Now, for "K" equal to 2, then 1, then 0, do the

a. Multiply Y times X (which is 1.2) and add the coefficient of
X-to-the-K-power. When K reaches 0, this is the so-called "constant term", +2 in
our problem. Let Y = this new value and throw away the old value of Y. In
computer talk, Y = Y*X + C(K), where "*" means "times" and C(3), C(2), C(1),
C(O) are the coefficients (from left to right) of our equation. Note that C(K)
means "C subscript K"-not "times K"and that the = sign really means "is replaced
by" rather than "is identical to".

b. Your last Y is the answer. Believe it or not, this is by far the easier way
to do our problem. This repeated application of a simple idea is the key to

6. A woman's work is never done, and neither is the programmer's.

You will nearly always find yourself rewriting programs. lt might work, but you
would like another feature added; or, it blows up if the user does something
stupid so let's check for stupidity on his part; or, it can be combined with two
or three other short programs to make the Pan-galactic Interplanetary Super
Solver that cures all ailments.

lt's like fine furniture: sanding, resanding, finishing, refinishing, until you
really like the looks of it.

7. When in doubt, guess. You don't know what will happen if . . . ? Well, try
it. Smart guess-work

Page 20 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails
This book is also available for the Kindle