Re:Why would you learn C++ in 2016?
by andrepd on Tuesday April 12, 2016 @10:34PM
(#11485294)
There are a few things I disagree, but at least one is factually wrong. C++ is as fast as C, if nothing else because it's (almost) a superset of it.
[ Parent
| on HN ]
The things C++ is missing include performance features. It's missing the "restrict" keyword.
https://en.wikipedia.org/wiki/Restrict
Some compilers offer "__restrict" or "__restrict__" in C++, but it's not standard. Standard C++ lacks the feature.
Besides "restrict", there is also the matter of theory not matching practice. The norm for C++ programmers is to be at least somewhat unaware of various extra copies and allocation. You know it's true. In practice, this makes the language slower.
C++ has std::valarray that has aliasing rules similar to the restrict keyword, allowing the same types of optimizations.
Forgive my ignorance, but doesn't std::unique_ptr communicate the same restriction, and therefore enable the same optimisations?