C/C++ Is Dead: Long Live C/C++!

Bjarne Stroustrup changed the programming world forever when he “invented” C++ (at the time, called C with classes). He did it purely to solve his problems with C, which were at the time was that C was a purely procedural language leading to spaghetti code that was very hard to maintain, difficult to extend, and only leant itself to systems programming. Little did he know that C++ would have a profound effect on the realm of computer science, and would eventually be the foundation of modern day IT as we know it, as well as being the foundation for the big two modern day programming languages: Java and C#. Not to mention the fact that C++ runs the code behind most of the world’s largest infrastructure: The phone system, the power grid, etc.

I learned the basics of C/C++ during my first round of computer science classes in the late 90’s (I’m showing my age by even admitting that) and thought to myself “there is nothing that C/C++ can’t accomplish when it comes to programming” which in most cases is correct. All modern day operating systems are programmed in C, and Windows is no exception. The entire underlying API’s are exposed via C function calls, with various C++ wrapper frameworks available (MFC, ATL, WTL, C++/CLI) available to simplify programming the underlying Win32 API, which is huge, enormously complicated, and arcane. The Win32 API has been around for almost 30 years and is very much showing its age, but Microsoft’s commitment (for the most part) to backwards compatibility has caused the Win32 API to become very bloated, hence the need for wrapper frameworks to simplify programming against the Windows platform.

When I learned C/C++, we were programming against SPARC mainframes, and UNIX systems. Stroustrup claims that C++ is portable, but the issue is that vendors can add their own extensions (such as Microsoft’s CLI extensions, which in my opinion cripple C++ on Windows to the point of almost being useless outside of the using the standard ANSI implementation frameworks), and that defeats the entire portability concept. Stroustrup has been very outspoken about vendors adding their own extensions, but I digress. My problem with C++ is that (by computing standards) it’s a dinosaur. The STL is a huge pain in the ass, and isn’t implemented correctly across platforms (again Microsoft, I’m looking squarely at you).

For a couple of months last year, I dove into C++/CLI hoping it would make me appreciate Microsoft’s implementation (I know the ANSI standard, but I program Windows for a living, so why not learn the MS “version”), and was horrified at what I found. Handles, references, de-references, pointers, everything is heap based (Java anyone?) for the most part, you can create both value based and ref based structs (defeats the purpose IMO, just make everything a class)…and what horrified me the most was Visual Studio 2010 does NOT support intellisense for C++/CLI projects! That all being said, Microsoft’s ANSI implementation of C++ is fairly spot on, aside from a few nitpicks.

I know there are C/C++ purists out there, and in the end most languages get compiled down to C/C++ before executing as byte code since the built in compilers for most OS’s can readily read in C/C++ and transform it into native code. And I guess that’s the point of this post, it’s this developer’s opinion that C/C++ has largely become an intermediary language. Computers are fast enough and have enough resources that we can use much higher level languages , and have faith in our compilers that they will emit the most effective and optimized “intermediate” language. As a systems programming language, C/C++ will never disappear, at least not for a while, but as a GPPL, at least within IT, it’s largely deprecated. OS vendors, and the big 4 software vendors (Microsoft, Adobe, Oracle, Apple) will always need talented C/C++ developers, but in the IT space, C++ needs a fork stuck in her.

I was very disappointed in my C++/CLI endeavors because in the end, I was out to make myself a better developer. All that endeavor did is make me appreciate modern day programming frameworks even more, in my case, .Net/C#. Could I write programs that perform better in C++? Sure, but is it worth the extra effort? Nope. Not at all. Modern day frameworks like JRE and .Net have their drawbacks, and can be resource heavy at times, but in the end we need to produce code that runs, and works. Hardware resources are cheap enough that it outweighs the extra man-hours it takes to write better performing code. That’s not to say we shouldn’t follow correct coding paradigms, but in the end, time is money. Do you want to pay a developer an extra month’s salary to save half a gig of memory in their application, or shell out the couple hundred bucks for a DIMM of RAM?

My final point is that many consider C++ to be an object-oriented language. It’s this developer’s opinion that it is not. Understanding inheritance chains in C++ is a monumental task, and isn’t as fine grained as it is in more modern languages. Multiple inheritance leads to HUGE maintainability problems in C++ projects. Keeping up with source and header files is a nightmare, and the rules around copy constructors are maddening. And of course the blaringly obvious, keeping up with pointers and references. I know there are C++ frameworks to help alleviate manual memory management (smart pointers), but modern day frameworks do a much better job, at less cost in terms of man-hours tracking down memory leaks.

Java and C#/.Net are not the end all be all. There are times when a component needs to be written in C++ for the utmost performance, but as the years click by I see less and less of a need for these. All professional developers should understand C/C++ conceptually, since in most cases the underlying API is written in one of those languages, and I will say that honing my C++ skills for the Win32 API has made me a more thoughtful programmer. But in the end, C/C++ is dead outside of systems programming. I’m sure Stroustrup would disagree, but we’re not all as brilliant as he is.

No comments yet