3 ms·
"Modern C++" at least partly refers to generic programming techniques that were popularized by Alexandrescu's book "Modern C++ Design"; a lot of the features in
by aidenn0 10y ago
"Modern C++" at least partly refers to generic programming techniques that were popularized by Alexandrescu's book "Modern C++ Design"; a lot of the features in C++11 improve language support for such techniques.
The term also implies use of RAII[1] which is a technique that was used at least a decade before C++ was an ISO standard.
The third implication is a rejection of what is often called "C+" or "C with classes" which is the treatment of C++ as C with a couple extra features. Since a lot of early C++ programmers were C programmers, and a lot of early C++ compilers were fairly mediocre in their implementation of language features[3], the 90s generated a lot of "C+" code.
Really the first two points are a subset of this one as they are two prominent examples of programming techniques that are fairly foreign to C, but are extremely valuable for writing robust C++ code.
So "Modern C++" really means "Something widely considered a good idea for about a decade" at this point.
If you work on a good legacy code base, the typical old oddness will be "Version X of MSVC/GCC/whatever had poor RVO[2], so we did this ugly thing for optimization" and (obviously) either a complete lack of using the features in C++11 or using a proto-version of them via Boost.
Even the nicest legacy code bases will have really odd things whose original motivation would require serious archaeology to divine, but that happens even with relatively static languages.
1: https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization https://en.wikipedia.org/wiki/Resource_acquisition_is_initia...
2: https://en.wikipedia.org/wiki/Return_value_optimization https://en.wikipedia.org/wiki/Return_value_optimization
3: Believe it or not, a lot of the code from Alexandrescu's book could not compile in either MSVC or GCC when it was published. The library that accompanied the book became incorporated into many compiler vendor's conformance testing.
- bogomipz 10y agoThese were all great comments thanks. Would people still suggest Alexandrescu's book "Modern C++ Design" as the best source for newcomers to learn modern C++ then?
- pjmlp 10y agoIt is one source yes. But you should also have a look at "Tour of C++" and "Elements of Programming". Also Microsoft has lots of Modern C++ talks on Channel 9 done by Stephan T Lavavej. https://channel9.msdn.com/tags/STL/ https://channel9.msdn.com/tags/STL/
- bogomipz 10y agoThanks for the recommendations. Cheers.