Hacker News new | ask | show | jobs
by C-- 4299 days ago
I feel they could have stopped with C++03. C++11 certainly introduced very few necessary features but this is just going too far. This is not solving any problems but in reality is causing new ones as introducing syntactical redundancies ultimately leads to everyone having their own preference, which in turn is a source for inconsistent and dirty code bases and bugs.

They should have taken a hint from all of those coding standards coming from companies such as Google, which basically constrain the programmer to a small subset of the language features.

3 comments

One rule of thumb I use for code is: Can you step through it in a debugger, at the source level, and have insight into what is going on? Because with really, um, "clever" code, you'll probably need to. And so will your cow-orkers. And if the code doesn't work or has limitations -- quite likely with creeping "clever" machinations like this one -- you'll get Spoken To.

(Yeah, this depends on how good your debugger is. Visual Studio and XCode are pretty decent).

This is the only metric worth paying attention to, in my experience. Whatever you do, your product will end up with defects, you'll need to get rid of them, and towards the end of the project there will always be a huge pile of them. (And, thanks to natural selection, only the hard ones are left. All the easy problems are long extinct.) So why not optimize for this stage? Even if you don't end up turning a time/effort profit overall - which is unlikely - you'll at least benefit from being under far less stress during what's always a fraught period.

And for whatever reason, C++ debuggers and debug info formats don't seem to be doing a great job of keeping up with the language. Even basic stuff like nested function calls (as easily found with any smart pointer/iterator or array class...) tends not to work very well, to say nothing of single stepping in to std::function, or watching STL types, or using iterators or smart pointers in the watch window. So this necessarily means being a bit conservative about which features you use.

(You might have to go through the shipping-a-product process a couple of times before you really internalize this. But once you've learned it, it really does stick.)

> C++11 certainly introduced very few necessary features

I have to ask whether you've actually done any significant amount of programming in C++, both C++11 and pre-C++11.

Honestly, it seems like the people who complain loudest about C++ have barely used it. C++11 is fantastic. C++14 and beyond are quite exciting as well.

I'd avoid Alexandrescu-style template trickery unless you really truly need it, though. You can write good C++ that more or less resembles Java, and that's fine.

> You can write good C++ that more or less resembles Java

That doesn't sound like good C++. Making everything a pointer or implementing polymorphism through pointers makes the code harder to reason about, and makes tighter coupling between interfaces and implementations.

Not to act too serious about nicks here, but his/er handle is "C--", after all.
> I feel they could have stopped with c++03.

You can still do this kind of horror with C++03. I'd know, I have!

Tests: http://sourceforge.net/p/libindustry/code/HEAD/tree/branches...

Code: http://sourceforge.net/p/libindustry/code/HEAD/tree/branches...

This was written shortly before I decided to stop fighting the language and simply use a better one for all of my hobby projects.