It May Be Crufty [4], but It's the Only Game in Town
[4] "Crufty /kruhf'tee/ [origin unknown] adj. possibly over-complex"—The New Hacker's
Dictionary, ed. Eric Raymond, Cambridge, MA, MIT Press, 1991.
Having seen some of the serious failings in C in the first few chapters of this book, it would be really
nice to say that C++ addresses these while retaining the flavor of C. It would be really nice, but it isn't
going to happen, because it isn't true. C++ has some point improvements, but it retains many of the
flaws of C, and piles up another big layer of complexity on top. The original C philosophy of "no
features that need invisible runtime support" has been compromised.
Software Dogma
Improvements in C++ Over C
- The error-prone construct of initializing a char array without enough room for the
trailing nul is regarded as an error. char b[3]="Bob"; will cause an error in
C++, but not in C. - A typecast can be written in the more normal-looking format of float(i) as
well as the strange-looking C style of (float)i. - C++ allows a constant integer to define the size of an array.
•
- const int size=128;
char a[size];
is allowed in C++, but will generate an error message from C.
- Declarations can be intermingled with statements, dropping the C requirement that
all declarations precede all statements in a block. It's great that this arbitrary rule
was dropped. Since this fix causes an incompatibility with C, why not go the
whole way and provide a simpler alternative that fixes the horrible C declaration
syntax, too?
Although C++ may be crufty, it's the only game in town. All the major players are behind
it. All new development at AT&T is said to be in C++ now. The graphics part of Windows
NT (which was later, slower and bigger than expected) was written in C++. Most new
software development tools, applications libraries, and advanced technologies are now
written in C++, or at least the ANSI C subset of it. But how long will it be before we start
to see spectacular bugs like the AT&T network shutdown, caused or aggravated by features
in C++ rather than C?