3 ms·
> I still like it, because (unlike C++) I can understand it No article like that is complete without a little C++ critique :-) > I think it’s the simple, idio
by bjarneh 6y ago
> I still like it, because (unlike C++) I can understand it
No article like that is complete without a little C++ critique :-)
> I think it’s the simple, idiomatic versions that are the most telling. This is the code programmers are likely to write in real life.
I very much agree with him on this statement. If people started writing "optimized" versions of algorithms (on that level); who would ever be able to read others peoples code...
- wirthjason 6y agoI saw a talk by Matt Godbolt demoing the compiler explorer showing showing the assembly between idiomatic C++ vs someone trying to outsmart the compiler. In all cases the idiomatic version was superior in performance and readability / maintainability.
- s3cur3 6y agoLink to the (great) CppCon talk: https://www.youtube.com/watch?v=bSkpMdDe4g4 https://www.youtube.com/watch?v=bSkpMdDe4g4 The one thing I would say is: as you dig more into C++ perf, you can develop an intuition for the kinds of things the compiler can and can't optimize. For instance, the C++ example from the article uses `std::unordered_map`, which is just an absolute mess from a cache locality perspective—the best compilers today (or of the foreseeable future) can't do a thing to fix that. Improving the programmer's choice of data structure is just not on the radar. :(