Essay Preview: C++
Report this essay
I have been using C++ for many years. Ive been using C++ almost exclusively since 1996 (although I have started to use Java for some applications). I have developed tens of thousands of lines of new code and maintained this code in a released product. A number of fairly sizable examples of my C++ code are published on bearcave.com. My experience with C++ over these years has given me a love/hate relationship with the language. I would certainly rather use C++ than C. Even when performance is not an issue, Ive chosen to use C++ over Java in some cases. I love C++ because it allows me to build complex software systems at a more abstract level than I could in C. I hate the language because of its seemingly endless complexity and seductive features (e.g., templates) which can lead into swamps of unmanageable complexity (just try debugging a deeply nested template). The size of the C++ language also guarantees that no two implementations will exactly match (see the discussion about portability on my String container web page). C++ code is much less portable than C code (just try porting code between Windows, Solaris, A/IX and HP/UX).
C++ has a long history. The language started out as an experiment in object oriented programming based on C. A front end translator read this ancestor version of C++ and generated C. This front end translator and its limitations affected the language, as did the design objective that C++ be as backward compatible with C as possible. Once C++ started to catch on these evolutionary features were joined by design by committee, which gave us features like dynamic_cast and the Standard Template Library (STL). It is interesting to contrast C++ with Java, which was never designed to be compatible with C (but rather is C based).
A programming language should support the expression of algorithms. It should aid the programmer, not stand in their way. The end result of the evolution of C++ is a language that forces the programmer to be constantly concerned with language features like constructors, destructors and copy constructors. The complex interactions of namespaces, header files, templates and static variable can take years to master. Complete documentation of complex C++ constructs requires that the programmer document not only the algorithm, but also the language feature, since the reader may not be familiar with all of the dark corners of this baroque language.
Developing large software systems in C++ is like swimming across a lake with a ten kilogram weight strapped to your waist. If you are a strong swimmer you can succeed at the task, but it would have been easier without that damn weight.
The idea that C++ is not unconditionally wonderful seems fairly radical. Almost as radical as the concept that object oriented design is not the solution to all of our software engineering difficulties. (Good object oriented design is