5 ms·
As someone who programmed in "classic C++" for decades, I feel like modern C++ is pretty different, and that it's not just syntactic sugar to make some ugly thi
by dfan 9y ago
As someone who programmed in "classic C++" for decades, I feel like modern C++ is pretty different, and that it's not just syntactic sugar to make some ugly things easier. The biggest example is that my natural inclination to use raw pointers everywhere and manage all memory myself, while idiomatic modern C++ is full of unique_ptrs and shared_ptrs everywhere, and raw pointers seem to be regarded as a code smell. Converting to this style is not an automatic process.
For people who are coming from a classic C++ background, I find Bancila's Modern C++ Programming Cookbook to be a good first stop for discovering modern C++ idioms.
- jcadam 9y agoI remember being placed on a C++ project for a few months after having been away from the language for almost 10 years. The lack of raw pointers was an immediate slap in the face and had me going "WTF am I looking at?"
- isaachier 9y agoOK from that perspective I can relate. Even before using C++11 I was using a lot of the new STL through Boost. If you use Boost, the only fundamental differences are syntax like auto, variadic macros, constexpr, noexcept, and lambdas all of which are familiar enough to get by. The only practical differences that have no equivalent in C++03 is move operations and maybe the threading/chrono stuff. Effective Modern C++ covers that so that's all I needed to "upgrade."
- AstralStorm 9y agoI suppose you shouldn't be using pointers if not required, not even smart(er) ones. They are not free and prevent certain kinds of optimization as well as allow accidentally sharing state.