C++ is such a contrived language

I’ve moved from C to C++ for a couple of years now, and every time I try to do something a little bit fancy I reach the limitations of the language, where I have to waste time to do really contrived things to make it work, because “architected” language features are actually hacked solutions more than a design with intent. It looks OK in a textbook, not so much when you try to work.

If the web search engines and Stack Overflow were not readily available, it would be nearly impossible to figure out the arcane behavior of the compiler.

C++ always promise to allow me to do something and in the end the little devil comes out and makes it all super complicated and forces me to give up or write some obscure, hard to parse solution.

Right now I want to make a simple macro that prints into a JSON format into a stream, and pass any type numeric, string or class object, and have it properly pretty printed. It almost works except char is printed as a character value, not an integer value, so it’s screwed up. I can use the unary + to print it properly, but it’s not defined for all types so it can’t be used in a macro that doesn’t differentiate the input type. And it’s impossible to special case char, use to_string(), reinterpret_cast<> or any other hack without being a master of C++ arcane-bullshit.
Here’s an example of C++ BS.

Another example is the irksome declaration of classes in headers that must include private sections, which breaks makefile dependency checks and trigger full rebuilds in large projects. Leeching shortcomings of the compiler into the language is a fallacy. I don’t care if the private section entries are needed by the compiler to properly handle linking. Hide that shit. And same with templates, which force you in some cases to declare source code in headers.

C++ is powerful, but also obscure and with obscure side effects that are artifacts of piling up features on top of a language over time without working them properly to become seamless.

With all the clutter of features and piles of standard libraries more or less optimized and leaking memory and corner case behaviors, C++ still compile code that is faster and more efficient than all the newer languages. The bar is not very high…

It’s amazing we’re able to build massive projects in C++.

We need a genius to revisit C and make it object again, but without all the failures of C++ or Java or other interpreted languages.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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