Tuesday, 11 March, 1997


Author's note:  This article originally appeared in Visual Developer Magazine, June/July 1997.  At the time, it pretty accurately expressed my opinion of the C++ language in general.  Over the past three years I've come to understand that C++ has many advantages over C.  C++  can certainly be misused, but so can any other tool.  I still take issue with some of the language's features, and when I write C++ I normally stick to a fairly small subset of its features.  The advanced features are powerful, but they're very difficult to use correctly.  And used incorrectly, those features cause far more problems than they solve.

Enjoy the rant.

Let’s see if I got this right. Take a small, elegant, and useful language, add operator and function overloading, default parameters, multiple inheritance, templates, and a dash of ambiguity for good measure, and then form a committee to really spruce it up. Cool. How about I take that brand new Ferrari, add a fifth wheel and 8 more cylinders, replace the electronic ignition with a random number generator, and then send it off to Ralph Nader for improvements?

If you haven’t read Scott Meyers’s Effective C++, you should. In fact, if you’re writing C++ programs and haven’t yet read the book, you’re committing malpractice.

Drop what you’re doing, go find a copy, and read it.


I’ll wait.

If you’re still writing C++ programs, you’re committing malpractice with malice aforethought. If you still think C++ is the way to go, read Meyers’s second book: More Effective C++. Further leanings toward C++ may require therapy. Surgery is indicated in extreme cases.

I hope Meyers makes a mint on these two books. He better do it quick, though, ‘cause his market can’t last. If more C++ programmers read these books, we’ll have fewer C++ programmers.

C++, like Ada and PL/1 before it, shows it origins. Who else but a committee could propose that the statement foo::~foo(); not only make sense, but be required by the language? It’s bad enough that C prompted an annual Obfuscated C Programming Contest. But to have C++ require obfuscation? Do you really expect me to believe that v3=v1*v2 is more clear than v3=vectorCross(&v1,&v2)? On what planet? Just what does it mean to multiply two vectors anyway?

Last week I caught a jackalope. It’s a funny-looking critter that inherits from jackrabbit and antelope. It was real easy to catch ‘cause when it decided to flee it didn’t know whether to hop or to run…

The ambiguity problems alone should have axed multiple inheritance and function overloading. That the standards committee "fixed" the ambiguity problems and plowed on ahead is further proof that the universe can always create a more ingenious idiot. That programmers actually try to make sense of and use these flawed features proves P.T. Barnum right yet again.

The insidious thing about C++ is that it’s so convenient to use. Nearly always pass FALSE for that last parameter? Make the default FALSE and don’t worry about it. How convenient!

Last winter I covered my pool. Darned convenient—leaves didn’t get in there and I didn’t have to check the chemical levels. Of course, when I uncovered it 5 months later the water was a rather interesting shade of green…

Convenience is not a valid engineering principle.

What are private data members doing in a publicly-visible place like a header file? The woman next door walks down her driveway nude every afternoon to get her mail. Or so I’ve heard. I’ve never actually seen her ‘cause I’m not supposed to look.

How can I be expected to take seriously a language that claims to be object-oriented but can’t even get a simple concept like data hiding right?And encapsulation? Ha! Change a private member and you have to recompile your entire application? If GM made cars that way, I’d be tripping back to Driver’s Ed every model year.

I haven’t yet decided which makes less sense: the U.S. Tax Code or the latest C++ Draft Working Paper. I can’t escape the feeling, though, that I really shouldn’t have to read either in order to get my work done.

So I don’t.

I pay an accountant to prepare my taxes, and I write my programs in C.