ugh.book

(singke) #1
The Assembly Language of Object-Oriented Programming 207

Hard to Learn and Built to Stay That Way


C++ shares one more important feature with assembly language—it is very
difficult to learn and use, and even harder to learn to use well.


Date: Mon, 8 Apr 91 11:29:56 PDT
From: Daniel Weise <[email protected]>
To: UNIX-HATERS
Subject: From their cradle to our grave.

One reason why Unix programs are so fragile and unrobust is that C
coders are trained from infancy to make them that way. For exam-
ple, one of the first complete programs in Stroustrup’s C++ book (the
one after the “hello world” program, which, by the way, compiles
into a 300K image), is a program that performs inch-to-centimeter
and centimeter-to-inch conversion. The user indicates the unit of the
input by appending “i” for inches and “c” for centimeters. Here is
the outline of the program, written in true Unix and C style:

#include <stream.h>

main() {
[declarations]
cin >> x >> ch;
;; A design abortion.
;; This reads x, then reads ch.

if (ch == 'i') [handle "i" case]
else if (ch == 'c') [handle "c" case]
else in = cm = 0;
;; That’s right, don’t report an error.
;; Just do something arbitrary.

[perform conversion] }

Thirteen pages later (page 31), an example is given that implements
arrays with indexes that range from n to m, instead of the usual 0 to
m. If the programmer gives an invalid index, the program just
blithely returns the first element of the array. Unix brain death for-
ever!
Free download pdf