C++ Snobbism

All of this has been pretty language agnostic so far, and with little effort can be extended to any topic, and not just to programming languages. However, I feel that C++ snobbism adds a twist to language snobbism that is not often seen elsewhere: I’ve encountered an unpleasant amount of C++ users that are incredibly dismissive of C, the language’s most obvious spiritual ancestor.

And I think that’s the most stupid thing that C++ users can do.

Don’t get me wrong here, I’d pretty much always choose C++ over C if I was asked which language I’d prefer to implement something in. C++’s constructors, destructors and RAII are features you don’t strictly need to use, but using them allows for such convenient shortcuts in so many different situations that I sorely miss them in C. Templates in C++ allow for some beautiful functional-language-like constructs1 that I find myself thinking in terms templates more than in terms of functions or classes. Sometimes that’s useful, sometimes it’s not, and striking a balance between conceptual appeal and usefulness is usually very hard — but the fact that the language supports such constructions is a source of joy to me.

So you can firmly place me into the camp of people who love using C++, despite it’s weaknesses. But still I can’t share the opinion of so many C++ snobs that C is somehow inferior. It’s actually a very similar situation to the comparison of Lua and Python: one is minimal, and very elegant in it’s minimalism. The other provides lots of stuff that can easily be abused, but when it’s used right, it’s conceptually beautiful in a way that the more minimal language cannot, by virtue of it’s minimalism, hope to encompass.

In the case of C++ vs. C, though, there seems to be a prevalent opinion that one must avoid using those features of C++ that are backwards compatible with C in favour of C++-only features. I’ve read people opinioning that free functions in C++ are bad and OO-style programming is the only sensible approach to structuring code. I’ve read that using pointers is bad, and that you should always use references instead — or you must use smart pointers if you can’t avoid pointer semantics. I’ve read that relying on the C preprocessor is beyond evil, although C++’s template syntax does not support all the things you can do with the preprocessor — and vice versa. The list goes on.

What most people don’t seem to realize is that the STL and boost — both of which C++ users generally consider to be good examples of C++ code — rely heavily on the above mentioned features, and wouldn’t work half as well if they didn’t.

Which is why C++ snobbism is so utterly stupid, even compared to any other form of language snobbism. Yet time and again you’ll find discussions about C++ code dominated by C++ snobs that express exactly these opinions. I can’t help but wonder whether that’s part of the reason many people consider C++ to be comparatively inaccessible.

  1. With the ugliest syntax known to man, but the concepts still remain beautiful. []

Leave a Reply