I'll link to my thoughts on language vs library which are in another comment; I fully recognize it's complicated to balance.
Another issue of layers upon layers of generic code, beyond compile times, is debugging.
Each time I try to step into a function call taking a dereferenced unique_ptr as argument, I despair. It'll take a dozen steps for dereferencing that unique_ptr as it goes inside unique_ptr internals, which somehow also go into tuple internals (used for the EBO for the deleter, I guess).
A dozen steps to get into a function call!
Now, we could argue the debugger should be smarter, however there's a fine line to tread there. If the debugger hides too much, such as skipping std code, then it doesn't make life easier. For example, it's natural to want to step into std::remove_if when the result is not to taste.
Hopefully, for this particular case, the upcoming attribute to allow 0-size data member should allow cleaning up the clunky implementation of unique_ptr; unfortunately, it won't help much with all the range (or std::function) machinery.
The first problem is solved with underrated MSVC's "step into specific". Personally I almost never use normal "Step into" anymore since it also gives great perspective as to what actually happens in debugged line.
Microsoft solved 'std::function' problem too, however their solution seems to affect performance in debug build a bit yet.
Generally I strongly believe that debuggers could and should get better.
In VS 2019, the debugger has a general “Just My Code” ability for C++, superseding the weird hack we used in std::function (now removed). We’ll continue to improve debug codegen with if constexpr but that regression should be gone.
Does JMC for C++ still require emitting a stub at the beginning of every function? This was a dealbreaker for me in VS2017 15.8, I can't tolerate that kind of impact in optimized builds.
19
u/matthieum Dec 28 '18
I'll link to my thoughts on language vs library which are in another comment; I fully recognize it's complicated to balance.
Another issue of layers upon layers of generic code, beyond compile times, is debugging.
Each time I try to step into a function call taking a dereferenced
unique_ptras argument, I despair. It'll take a dozen steps for dereferencing thatunique_ptras it goes insideunique_ptrinternals, which somehow also go intotupleinternals (used for the EBO for the deleter, I guess).A dozen steps to get into a function call!
Now, we could argue the debugger should be smarter, however there's a fine line to tread there. If the debugger hides too much, such as skipping
stdcode, then it doesn't make life easier. For example, it's natural to want to step intostd::remove_ifwhen the result is not to taste.Hopefully, for this particular case, the upcoming attribute to allow 0-size data member should allow cleaning up the clunky implementation of
unique_ptr; unfortunately, it won't help much with all the range (orstd::function) machinery.