Skip to content

Comment on Defective C++

Comments

This page is about C++98. C++11 and 14, while making some important things easier, have their own set of problems.

Which is why Yossi Kreinin called for help about updating the FQA for C++1x and beyond. As he no longer works with C++, both his expertise and the time he can waste on this language are dwindling. http://yosefk.com/blog/c11-fqa-anyone.html

A good FQA and a great blog post summary.

And you can see the same shrewdness, the same "altruism", the same attention to detail, the same tunnel vision – "this shit I'm working on is so important, it deserves all of my mental energy AND the mental energy of my users at the expense of caring about anything else" – throughout the C++ culture. From the boost libraries to "Modern C++ Design" (the author has since repented and moved to D – or did he repent?..) to the justifications for duplicate and triplicate and still incomplete language features to your local C++ expert carrying his crazy libraries and syntactic wrappers and tangling your entire code base in his net.

So true.

In the beginning of my career, I too was drinking the C++ koolaid. I really believed that manual memory management, large and convoluted class hierarchies, obscure template programming, cryptic exception handling, and pointer tinkering was necessary in a language and, of course, to get good performance you had to use C++. What a complete lie.

I still meet programmers who believe that, because it is important. And then you look at what kind of software they are writing, some desktop app or some web service. Huh.

If you look where the C++ community ended up by C++ programming experience over the years is that you should probably avoid all of that if you want bug free code.

I really believed that manual memory management, large and convoluted class hierarchies, obscure template programming, cryptic exception handling, and pointer tinkering was necessary in a language and, of course, to get good performance you had to use C++. What a complete lie.

It was a complete lie. Fortunately, none of that stuff precludes you from using C++.

True, and when I need to use C++ today I use a small subset of it with some new features from C++11. Namespaces, functions, structs, lambdas and smart pointers is usually all I need.

The standard library has become so much better then the old days. Now I can even create threads without extra libraries. Unfortunately std types are no longer COW with C++11.

Now if I only can get rid of that awful header file I almost have something that works without too much headache and profanity.

Unfortunately std types are no longer COW with C++11.

GNU std::string being CoW (still is atm btw) has always been deceitful. The API was simply never designed for that implementation, which resulted in seemingly cheap read-only operations (char x = str[42];) becoming quite expensive.

I'm glad you mentioned actually, since API authors embracing reference semantics through fear of overhead is a great rabbit hole of systemic complexity for C++ developers who are then forced to swim against the tide in the language. Sadly I don't think Rust goes far enough in bringing love to value semantics.

Ah, I did not know that. I mostly use CoW when I do Qt stuff to get a clean API (but Qt gives you whole range of other annoyances). Qt data types works well together with std lambdas without the need of smart pointers.

In what other language has so many Stack Overflow threads and blog post been dedicated just how to pass a simple parameter to a function. And with C++11 we have one more way of doing it. It is really mind-boggling.

I never have this problem in other languages and I can do equal the heavy lifting.

And for the C++ programmer it gives a false sense of satisfaction when spraying the code with const& everywhere. I saved performance!

Just bizarre.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.