3 ms·
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.
by andrepd 11y ago
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.
- burfog 11y agoThe things C++ is missing include performance features. It's missing the "restrict" keyword. https://en.wikipedia.org/wiki/Restrict 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.
- mhaymo 11y agoForgive my ignorance, but doesn't std::unique_ptr communicate the same restriction, and therefore enable the same optimisations?
- firethief 11y agounique_ptr has unique ownership; it's not an error to use other pointers to the same data (just a bad idea).
- bitbiter 11y agoC++ has std::valarray that has aliasing rules similar to the restrict keyword, allowing the same types of optimizations.