|
|
|
|
|
by travisgriggs
2757 days ago
|
|
“Boden is written in modern C++11 to make development easy...” They lost me there. I admit I haven’t done any true C++ in the last few years, bowing at the height of Boost. So I’m curious, did I miss something in the next chapter of “modern” or perhaps the “11” that suddenly made C++ development “easy”?? It was quite capable for sure, but easy, no. Honestly curious. Maybe I’m just not a good enough developer. :/ |
|
* They added smart pointers that actually work. (std::unique_ptr and std::smart_ptr) Invoking delete is considered a code smell in C++11, and new is considered a code smell in C++14. (because of make_unique and make_shared, added in C++14)
* Dynamic polymorphism (via inheritance) has gone out of style. These days it's templates all the way down, which aren't terrible anymore for a wide variety of reasons that I don't have time to go into.
* Threads and safe locking mechanisms are now actually standardized, so you don't have to use boost::thread. std::async, lambdas, and std::future provide reasonable syntactic sugar around threading, as opposed to manually mucking around with your own thread pool.
* Stuff that used to require library writers to dig around in the bowels of template metaprogramming became a lot easier with `if constexpr` in C++17. Actually that's one of the reasons why templates aren't terrible anymore, sorry for going into it when I said I wouldn't.
Idiomatic C++17 code feels like a completely different language than C++03. Ye olden C++ felt like Java with spike traps and no garbage collector, but idiomatic C++17 feels like... I dunno, Rust without the borrow checker and everything is in an unsafe block. (I'm trying to think of a better example)
(as an aside, there are two different things called "modern c++". I'm pretty sure it's a joke, but it's a terrible one. There's Andrei Alexandrescu's 2001 book Modern C++, and there is are the coding practices that evolved out of the development of C++11/14/17.)
Source: I maintain a ye olden C++ codebase at work, and write modern C++17 in my personal projects. The degree to which they differ is profound. I'm not doing the difference justice.