C++ Mutter

Somehow I always disliked working with C++. I never knew why, though. In my opinion, the language is very powerful, have a lot of features, recent C++11 and C++14 standards are bringing it to a new level. Amount of libraries are almost endless. It works on almost every device. Backward compatible to C. Object-oriented - inheritance, abstractions, polymorphism, everything is present. Fast. To overcome manual memory management - we have smart pointers.

And now I totally understand what I do not like in C++. It’s compiler.

It doesn’t matter if it’s gcc or Microsoft’s compiler (never tried clang, though).

First of all, it makes me repeat myself against my will. Header files are totally evil. If I want to change a signature of a function - I have to make change twice. That’s a violation of DRY principle. I understand the idea behind the header files, but I think that somehow they should be generated automatically, from C++ source. If C# manages to work without header files, C++ can too. Metadata should be hidden from user, until really needed.

Another point is the error messages. Instead of pinpointing the error, and it may be a simple one in the syntax, the error output can be very confusing. Recent examples - saying that class should be an abstract, when mentioned class is not abstract, but the class it inherited from is. Here you can witness a competition: about generating a longest error message in C++. People succeed to produce gigabytes of errors in couple of lines. To be honest, linker adds of frustration on each unresolved external problem. Also, fixing one compiler error leads to bunch of other. Each C++ programmer felt like this poem:

99 compilation errors found in the code
99 compilation errors found in the code
Fix one compiler error found in the code
127 compiler errors found in the code

Had to say it.

Actually, I wish that compiler will be our friend and not the enemy. Actually, I think of them like of school teacher - it gives grade, but in the end, he’s mission is to teach the subject. May be I’m just not so good at c++ as it looks :)

That’s all for today!