What is C++ Code Anyway?

  • warning: include(/tmp/fortune.txt): failed to open stream: No such file or directory in /home/mohawksoft/org/www/htdocs/includes/common.inc(1696) : eval()'d code on line 1.
  • warning: include(): Failed opening '/tmp/fortune.txt' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mohawksoft/org/www/htdocs/includes/common.inc(1696) : eval()'d code on line 1.

Often times I see people criticize source code written for C++ as not "C++" code. Somehow, even though constructs like printf(..), malloc(), and so on are supported perfectly well in C++, others call in to question their use.

I admit it. I don't like a lot of what C++ has become. I'm not trying to be an old codger, but C++ has become a language in which it is increasingly easier to shoot yourself in the foot. It is too easy to obfuscate functionality. It is too easy to write code in which it is almost impossible to really know what is going on. Beyond that, there are a lot of very powerful tools in the C++ tool chest but almost no "best practices" on what NOT to do with them.

I have seen numerous C++ projects that are almost impossible to navigate. Sure, the original author knows exactly where to find things, but later additions to the team are lost for some time until they come up to speed. Sure tools like IDEs such as eclipse and even ctags helps this, but it is still a problem.

Unfortunately, Java is in chaos, but Python is getting better. Perl is for all intent and purposes a write-only language unless extreme discipline is exercised. Then there is C, well, its the mirepoix of computer languages for sure, but it lacks what have become the basic constructs for effective software development. Too often you end up writing bits and pieces that are implemented as part of other languages just to have an intelligible design. You don't have to look much further than the GNU GTK to see this brought to absurd extremes.

So, like it or not, if, for what ever reason you can't use a higher level language and don't posses a masochistic streak, you are doing your project in C++.

C++ was designed to be an extension of the C programming language. That's how I fondly think of it. I intentionally use "non-C" features sparingly. The best phrase used to describe how I use C++ is as "C with classes." Doing so allows you to keep the basic intelligibility and efficiency of C but with the more modern constructs that have become staples in software design.