Interesting rant about C++

Perhaps it’s a bit of confirmation bias, but it’s nice to see an experienced C++ programmer articulate some of the things that I, as an experienced C programmer (~20 years), but inexperienced C++ programmer, am feeling about C++

Over at Pro-Phi-Psi, Why I No Longer Like or Use C++.

Some choice quotes:

I wish the C++ people would wake up and realize that C++ is drowning in its own complexity.

… C++ has no ABI

Translation, if you write a C++ library, only other C++ programs can use it, and then, then, there is a high likelihood of having to recompile it anyway when the underlying libraries (e.g. STL, Boost, or, for fuck’s sake, the fucking compiler) change.

One of the odder quotes is this:

Basically I got sick of every single aspect of C++ being designed around higher performance instead of my productivity.

I suppose that’s true — apart from some details expressed by a commenter:

A lot of posts here seem to be accepting the premise that C++ is necessary or desirable for runtime performance. No!!! C++ is not necessary for runtime performance. Other languages like C will do fine. In general, the more abstract your program gets in C++, the slower it gets, because of constructor/destructor/copy overhead, virtual pointers, etc.

Bingo! This crazy construct/deconstruct business which, as it turns out, implies a whole shitload of copying seems to me to be not particularly performance oriented. The objections voiced by seemingly experienced C++ programmers are lining up fairly exactly with my own conclusions. But, one must always be wary of confirmation bias.

One thing in my own (very limited) experience with C++ that stands out is a very marked lack of confidence in the correctness of my programs. That is, the compiler is sort of doing things “behind my back,” as it were, and no matter how many books I read, or how well I might think I understand what the compiler is doing “behind my back”, my confidence is less than with C, where the compiler does very little behind my back, and the things which it does do (optimizations) have, by experience, been things which were not inconsistent with the code I wrote. By contrast, C++ may write a default copy constructor, and if I happen to have forgotten to provide one for a class, no warning is forthcoming, but none the less, the STL will quietly proceed to commit suicide some considerable time after ingesting a class without a reasonable copy constructor, leaving a trail of clues — er, no, wait, I mean, leaving next to no trail of clues.

Isn’t the STL supposed to make life easier? Yet, if you look at it wrong, it attempts to kill you with no warning. This is, I suppose, the sort of thing which was meant by, “Basically I got sick of every single aspect of C++ being designed around higher performance instead of my productivity.” (emphasis mine.)


Unfortunately, for the foreseeable future, my job may involve a hefty amount of C++ programming. Maybe I will learn the pitfalls well enough to not hate it so much. But, reading the posts of experienced C++ programmers who seem to have the same basic problems that I do with the language, and libraries, and who have left in disgust, and reading the postings of those who still like C++, who make excuses for the language, and essentially blame the programmer who doesn’t like it as being not good enough, or whatever…” Hmm. It strikes me that the folks that are leaving C++ have the stronger argument. If C++ is meant to make life easier for the progammer, to make programs more, rather than less maintainable, and loads and loads of C programmers find that this is not actually the case, find that C++ makes life more, rather then less difficult, well, what is to be concluded? I am hard pressed to conclude other than but C++ is, as a language, a failure.

I attribute C++’s success to date largely to Microsoft’s embrace of it, particularly, the Microsoft Foundation Classes, or MFC. In the Unix world, the interface to the OS, all the system calls, and libc, make C the “lingua Franca” of the Unix and linux world. On windows, C++ occupies this spot — the interface to the OS and standard libraries is, from the application programmer’s perspective, a C++ friendly interface, and given that C++ has no ABI, an interface which is actively hostile to other languages.

With Windows being the defacto standard OS on PCs, little wonder that C++ succeeded despite its faults. With Microsoft now pushing C#, this advantage is no longer such a strong thing, though the army of C++ programmers who’ve mastered the quirks by means of hard fought debugging sessions are perhaps unlikely to abandon the C++ wagon overnight.

I don’t know… It’ll be interesting to see where I stand on this after a year or two of C++ programming. I kind of doubt that I’ll change my opinion though. I’ve seen sort of enough already in a way, and I tend to be of the mindset that a solution to a problem should be “as simple as possible, but no simpler.” The nature of C++ programs seems to be to have a strong bias to make things “as simple as possible while still solving the general case with a nice API (iff you’re good at API design, and are working on a well understood problem, and not figuring out the problem as you go), and conforming to the complex constraints of the libraries used… uh… so that generally means.. er, not very simple at all.”

So, I’m a bit discouraged with C++. I was hoping I’d grow to like it more than I seem to have. Back in 1989, when Turbo Pascal 5.5 came out with a load of object oriented features, I thought it was cool as shit, and embraced it whole heartedly, and used it for awhile, and got into it. But, it was a pretty isolated, small (DOS) environment, and, even then, I ran into limitations, and excessive complexity as a direct result of the OO paradigm…

Maybe I’m just a too “low level” “close to the hardware” kind of guy for this ridiculous amount of abstraction to be appealing to me…

Ok… enough of a rant for now, I suppose.

I’m sure there are loads of folks with different opinions than mine on this. For those people, bear in mind that I spent the entirety of today at work figuring out a bug resulting from a class that lacked a default assignment operater overload that was used with STL vector — not my code, mind you, but the way that it crashed — when the program exited — proved pretty difficutl to debug, even when asking an experienced C++ programme to help me. STL is supposed to help you, not stab you in the face. And all this debugging is a result of bugs in code which exists largely for reasons which have fuck all to do with the ultimate problem which is meant to be solved. Sure, any complex problem is going to have code which is abstract, and removed from the problem at hand, but in this case, had the program been written, in say, C, I am 100 percent positive I wouldn’t have wasted my day in this completely fucked up disgusting way. Very disappointed, I am.

~ by scaryreasoner on August 8, 2008.

2 Responses to “Interesting rant about C++”

  1. I feel your pain. But it looks like I will be doing a lot more C# coding soon, so I’m happy about that.

  2. There is a very good critique of C++ here:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: