An interview with a C++ guru



Bruce Eckel, the C++ author, educator and a foundation C++ committee member, flew into Sydney from the US last week to talk at the Borland World Tour. I spoke to him on his arrival:

SG: Your first book "Using C++" was the second C++ book I bought and the most worn, that was back in 1989 and then it was one of the very few texts available on the language. Now it seems like there are hundreds. You weren't just an early author, you were an early C++ expert, what was the moment or the project that opened your mind to C++, to the extent of dedicating your career to it?

BE: Your right about the number of books, it was easier for authors to get a reader then. The project where I first used C++ was kind of interesting. I was working at the University of Washington's school of Oceanography as a researcher, for a guy called Tom Keffer back in 1987. His goal was to stop people in the field from using Fortran. He saw Fortran as primitive and a time waster that kept people from their real work, so we set out to change their ways. I looked at three new languages as potential Fortran replacements: Objective C, C++ and one other.

Back then we were using the C++ compiler source code directly from AT&T. I had to compile AT&T C source code into the C++ compiler first. There was no documentation, so I learnt the hard way - from the compiler source code itself.

SG: I met a Dr. Tom Keffer from Rogue Wave Inc. at ASD92 in Sydney, is that the same guy?

BE: Yes that's him. He left the University and started his own company. They sell the MATH.H++ object library. It started from our early ideas back then on objects for math. He is a very, very meticulous man and I recommend his product - and I am not in the habit of recommending products. He has achieved much of the original goal to replace Fortran in technical fields.

SG: Your consulting company is called 'Revolution2', no doubt meaning C++ and OOP is the second wave, the software revolution, after the integrated circuit (IC) and the PC revolutionised the hardware market. Now that we have OLE V2 in Windows, SOM in OS/2 and COBRA defined as a standard for anybody else, how close are we to that revolution that you foresaw so early on?

BE: The name Revolution2 has multiple meanings for me and one of those does refer to objects as software IC's. As for the three object sharing methodologies you mention, OLE V2 is my bet. The others are still having problems coming up with the goods. At least OLE V2 is working now. It will happen because it is there. Windows NT, 32-bit Windows, is a steam-roller, it's going to be huge.

The Object Management Group responsible for COBRA are a funny bunch. They represent a set of diverse competing companies. It's hard for such a committee approach to succeed.

Sure I am on the C++ committee, but I am typical of the people on that committee. I am there for the good of the language, I am not selling a C++ compiler, I have no direct vested interests. That's why the C++ committee has been effective.

SG: NextStep for the 486 has just become available, do you think they made a big or a little mistake basing development on Objective C rather than C++?

BE: Well the original Objective C people are no longer in business, but (long pause). Steve Jobs has always pushed the envelope. He chose Objective C then because he thought it was the best. His real mistake has been to concentrate on selling the hardware rather than the software (NextStep) in the first place. Its the same mistake he made with the MAC at Apple. If Apple had put their software on other platforms, there probably wouldn't have been a Microsoft Windows. There might have been just Apple and Next right now. Had that been the case I might be here talking to you about Objective C instead of C++, they are both object oriented.

But now Windows has won, it's easier to use, cheaper to access, it's everywhere. In the meantime C++ has been enhanced and has matured as a language - not always for the better. For example Bjarne Stroustrup (inventor of C++) only put in Multiple Inheritance at the continuing insistence of AT&T. Runtime issues were a problem. The monolithic class library of competitor Smalltalk, was the reason behind AT&Ts insistence. Smalltalk enthusiasts were full of fire. Multiple Inheritance was included in C++ to handle container classes.

Since then Templates have been added to the C++. Templates are much superior in handling most situations where previously you would use Multiple Inheritance. In retrospect I believe Multiple Inheritance was a mistake. As an educator I need and use examples. Give me a good class room example of Multiple Inheritance? - 'Airport runways' and 'ice-cream'! That's the sort of examples you'll see in most books.

SG: The only good example I can think of, is the writing of the event-handling GUI itself. While we are on the subject of Templates, as a C++ committee member, can you tell me of any forthcoming aspects of the language that will have as significant an impact to the way we code in C++, as Templates have done?

BE: Well there is Exception Handling. Even though that went into the standard about a year and a half ago, it is only beginning to appear in products now. Technically, including Templates into a compiler is far easier than including Exception Handling has proved to be. Putting in Templates was simply like including macros in the language itself.

Exception Handling gives your routines an alternate return mechanism. It provides new ways to guarantee that errors are handled correctly. You need to do that to make libraries truly reusable.

Exception Handling uses the 'try' statement: open curly-bracket, catch float overflow, catch integer overflow, etc., close curly-bracket. It is like a switch statement but on 'type' rather than on 'value'. You can get anything you want out of a routine, any object, as you leave it.

SG: What, you mean that as you leave the scope of a routine, you can receive a new object that was created in that now defunct routine?

BE: Yes that's right, but it's not for regular processing, it is for bad situations only. Say you create eight new objects in your routine. At runtime you successfully created six of them before an exception takes place. With Exception Handling, the destructors for those six that were created, will be activated so the routine closes them down properly.

Of course in C you could do alternative returns in a very primitive low level manner using setjump and longjump instructions. But you couldn't do the equivalent of calling the destructors for those six successfully created objects.

SG: I still come across die-hard C programmers, friends amongst them, who will not concede the significant advantages of C++ over C. They point out that my projects aren't finished any faster than before, to which I answer: That's because with C++ I can put far more sophistication into the program than I could have in C, so I take the opportunity to do so. You must still suffer the same sort of resistance from time to time, what do you say?

BE: I come across Cobol programmers who won't move - that's personality you're coming up against, not logical argument. Personally my productivity increased about ten fold going from C to C++, but as Rod Murray said: "C++ front-loads the design process." The Windows interface is a learning curve. OOP is a learning curve. Class libraries are a learning curve. But once you're over the learning curves, then you compare, and you do it on a fixed specification.

C++ makes team sizes smaller. You can do far more with fewer people, and solve more sophisticated problems. Andrew Koenig said: "The problems in conventional languages are about twiddling bits, while in OOP you are dealing in concepts." The level of metaphor has been raised significantly.

SG: Bruce, you are a natural educator. Your style is one of maximum effort to impart your extensive knowledge to those that read your books or listen to you. As such you are a very effective spreader of the C++ word and thus a significant contributor to the second revolution. Is C++ your last language?

BE: Kind words. I guess I learnt C++ hard so I try to save other people from that experience. And no, I'll only stay with C++ for so long. I'll jump ship when the next best thing comes along. I've looked seriously at code-generators, that generate C++, and for many situations they are a better magic wand.

The next step is the visual programming environments. Visual C++ and .VBX controls are interesting. Visual BASIC V3 is cool. But more interesting are things like the new version of Protogen V3 and a product called Windows Maker from Blue Sky. They are far more sophisticated than Visual C++. The choice of code they generate is either: Object Windows (OWL), Microsoft Foundation Class (MFC V2) or zApp.

This is the future. Programming for Windows is art, and the artist I have the most respect for is Picasso. He developed and mastered a technique, then moved on. He did that at least twelve times. I'll buy anything to make my programming easier and faster.

(CUTTING CODE column, Computer Age, The AGE, 10th August 1993)