Hacker News new | ask | show | jobs
by fauigerzigerk 4484 days ago
The entirety of C++ initialization rules has become a byzantine mess of epic proportions and any change is bound to add another level of combinatorial explosion. There's just no way out of it.

I can tell you how C++ will die. It will die because all C++ programmers will soon be dead for one simple reason: Our brains are incapable of knowing C++ well enough to write safe C++ code and knowing something else at the same time.

Knowing all the rules and exceptions to those rules in C++ will overwhelm the neocortex of C++ programmers and start to usurp older parts of the brain to the point where heart rate and body temperature get out of control and they/we all die an agonizing death.

As a C++ programmer I am struggling right now trying to leave this path to seemingly inevitable doom. But the insane complexity of C++ has this addictive allure of making me feel so incredibly competent and important, a bearer of secret knowledge that underpins the world's most important systems.

4 comments

Honestly, writing safe C++ code means just following a few rules of thumb. Most importantly: never do pointer arithmetic, always use smart pointers.

Basically, 99% of your work should use only about 10% of the feature set of C++ explicitly. The vast majority of the time, you shouldn't even write templates (just use the ones in the STL and project-specific ones that make sense).

But it's really nice that those other 90% of features are there when you need them.

Your 10% is going to be different to my 10%. Almost all the C++ code I write includes new templates. Almost none of it includes inheritance.

I rarely use smart pointers that aren't implementation details (private class members)

Their should be a guide about how to write modern and unclutered C++ without the 90% of it.
And a compiler that only accepts the 10%.
"C++: The Good Parts"
Part of this is Scott Meyers style. I have nothing against him personally, he just presents a different perspective, which is important, but for me he doesn't really write or talk about C++ in a way that is very useful to me as a C++ programmer.

Several of the techniques he promoted in 'Effective C++' (an old book now, I will concede) are and were, imho, somewhat unhealthy for the sake of being cautious. Another example are his recent talks on "universal references", introduced a whole fuzzy concepts to paper over one simple rule when rvalue references are combined with templates and type deduction.

His 'grunt on the ground' comment is typical of his humour, but he's really a bit of a navel-gazer... I don't think the difference between direct and copy initialization for type deduction of initializer lists is really going to make a difference to most C++ programmers work. The C++ committee generally does a very good job, and the fixes introduced by this change will most likely make a much greater positive impact.

Same here. C11 has driven me into mobile app development with Java and Objective C. And that's after 10+ years of C++ experience and most people consider me a C++ expert.
Do you mean C++11, rather than C11?
Yes.
Ah, I found the inevitable "C++ haters" thread.