Here are two complementary (but not entirely complimentary!) blog posts about C++.
Roshan James has a scathing article about C++. When asked to recommend books on C++, he replied that he doesn’t recommend C++. He explains how the best C++ books may be Scott Meyer’s series Effective C++ but argues that they should be called “Defective C++. ” He isn’t criticizing Scott Meyers, only the aspects of the C++ language that made it necessary for Scott Meyers to write such books. Effective C++ explains how to get around problems that don’t exist in more recent languages.
Bruce Eckel’s article The Positive Legacy of C++ and Java focused more on what C++ did well. C++ was designed to be backwardly compatible with C. Bjarne Stroustrup, original author of C++, realized that the decision to be compatible with C would cause major difficulties, but he also thought (correctly) that without such compatibility no one would move over to the new language. Given this severe constraint, C++ has been remarkably well designed.
Update: Check out the C++ FQA site Alessandro Gentilini mentions in the comments. “FQA” is not a typo. It stands for Frequently Questioned Answers.
8 thoughts on “Two perspectives on the design of C++”
“C++ FAQ Lite” vs “C++ FQA Lite”
Julian Smith wrote a great article explaining his own disillusionment with C++ and more. He wonders if Effective C++ is actually part of the problem.
Stroustrup’s “Design and Evolution of C++” is a truly fascinating account of the forces which have shaped C++. Probably worth holding back on getting a copy for a year or two, though: I suspect he’ll be updating it for C++0X.
I’m a fan of using the language that I think is most effective for the task at hand. I’m still an advocate of C++, because it’s easy for me to write fast and efficient code. Since C++ is compatible with C, it makes it easy to write native libraries to extend the functionality of other languages (I coded a lot of JNI in my time as a software developer). C doesn’t have enough for me there, though it still is an excellent tool for kernel and driver development.
That said, I like Java a lot for whipping something together (I understand that Python is good for this too, but I haven’t really used it yet), because of its huge API, and I use MATLAB when I want to try out something mathematical, or when I want to munch on some data. Since there are so many choices when it comes to language these days, I don’t see why criticizing C++ is even relevant anymore.
I agree that there are “many choices when comes to language these days” IF you’re willing use a runtime: JVM for Java, CLR for C#, etc. But if you want to compile down to native code, the mainstream options haven’t changed in a couple decades.
Right. But the other side of the coin is that nobody seems interested in improving the state of the art in that arena. All the effort seems to be going into compiler research and not into designing a better language for native code (though I’m not in PL; I could be full of it), and there are other choices, like Ada, but nobody uses them.
Much of the complaining about C++ is either from hardcore C users or from people who don’t mind using a runtime. I’m personally not averse to having a runtime, as long as it doesn’t get in the way. I guess the point that I was trying to make is that for the majority of software, you don’t necessarily need to be super-sleek, or there are libraries that you can take advantage of that have native acceleration, so you do often have the choice.
There’s certainly less need these days for the kind of efficiency C++ affords. I do a lot of numerical computing, and it’s not uncommon for a program to run for hours. But development time still exceeds execution time.
On the other hand, I like the way MFC/C++ programs are lightening-fast compared to .NET/C# programs, especially in terms of time for the program to load.
(By the way, the time it takes boot a computer and do other common tasks hasn’t improved in twenty years.)
Re: MFC/.NET: I think that’s true. Though I have to say that MFC is nightmarish to program. It’s basically got it all wrong. A friend of mine used WTL (which was built right on top of the Win32 API), and had really good success with it. It’s just too bad that there’s no support for it.
Re: Boot time: I think that’s another issue entirely, as you mention in your link. :-)
Regarding languages that compile down to native code, I’ve heard good things about the D language though haven’t used it myself.