One problem for trying to just learn "modern C++" (so, C++ 20 and explicitly preferring the modern "right" way to do things, Kate Gregory talks about teaching C++ this way) is that C++ got this influential partly by having a lot of libraries. But for a library author, choosing C++20 over C++11 (or worse) means fewer users.
So, sure, all the code from people learning "modern C++" is smart pointers and ranges, but to get work done you have to call this library that takes raw pointers and you're immediately out of your depth.
raw pointers.. or homegrown strings, vectors and hash tables.
C++ soldiers on because it can support such things and adapt to decades of changing hardware and philosophy. But the pain of using and composing libraries in C++ is not just about not having cargo or npm - it's the lack of consensus on data types for anything beyond C primitives.
There's nothing ugly about Qt. In particular, the core system defines a way to add features to classes that were missing (MOC) and provides a full foundation of types up to network and other event-driven multi-threaded servers. Frankly I think it's one of the best examples of C++ I've seen.
> Smart pointers are a weird example because they're ancient.
I am an old man, and to me 2011 doesn't feel ancient, but fair. C++ 11 has unique_ptr and shared_ptr (if your library uses a previous generation of smart pointers you're in worse trouble than if it had raw pointers) and that's what you'd probably teach in class today.
> Also it's still completely normal to use raw pointers or references when a function doesn't care about ownership.
This is true. So you can't tell. And, with a different hat on it's also something that Kate Gregory has given talks about. As the new maintainer for several MLOC of C++ what can I conclude about this function that takes a raw pointer to a foo ?
Maybe, it just wants to look at a foo, immediately and then has no further interest in it.
Maybe, it will mutate the foo, immediately, and then loses interest.
Maybe, it will hang on to this pointer and use it later, who knows when. Thus, now it "owns" the foo, I hope it will clean up after it ceases using it because I can't now.
Maybe, I'm supposed to provide an "empty" foo and the contents of it afterwards are the primary result of the function.
Those are pretty different, so it's disappointing that we don't learn which it is from the function signature.
Huh. There simply aren't that many C++ compilers in the world that matter... who is working with a C++11 compiler, but doesn't have at least C++17? (The core problem with C++20 is that support is still spotty: like, I am waiting with baited breadth for clang to finally get around to P1091R3/P1381R1... they list it as "partial", but it feels like "not even started".)
So, sure, all the code from people learning "modern C++" is smart pointers and ranges, but to get work done you have to call this library that takes raw pointers and you're immediately out of your depth.
reply