4 ms·
Why it took so long is that: (a) C++ is an international standard, has a huge installed base of business- and mission-critical software, probably billions of l
by eric_niebler 8y ago
Why it took so long is that:
(a) C++ is an international standard, has a huge installed base of business- and mission-critical software, probably billions of lines of code, tens of millions of programmers, and we can't afford to get things wrong (though we still do sometimes).
(b) Nobody has built a large, _very_ generic, general purpose, high-performance library, on top of the (also new) C++ concepts language feature before. We were figuring it out as we went.
(c) While standardizing this piece, we were also thinking 5 to 10 years down the road and trying to make sure what we were standardizing now would evolve well. For instance, we already know pretty well what using ranges with coroutines will look like (i.e., reactive streams). We already know what other lazy range adaptors we want, and we know they work with the bits we're getting for C++20. We know how to integrate eager adaptors that transform containers and compose. This all needed to be built, tested, and well-understood.
As for why it is `std::ranges::sort` instead of `std::sort`, this exercise wasn't just about adding overloads that take ranges instead of iterators. It was also about rigorously specifying in code what the requirements of each algorithm are. For Reasons, we can't just slap new requirements on old algorithms that have been shipping for 20 years. It will break mountains of code. Nobody likes having two `sort` algorithms in two different namespaces. It is preferable to the alternative.
- saagarjha 8y agoI’m still not getting your argument. Why is this not “just adding overloads”?
- kbsletten 8y agoSounds like they wanted to be a little more aggressive rather than just putting lipstick on that same pig. By specifying the new method they can clean up the rough edges for performance or ergonomics without breaking existing code.
- CJefferson 8y agoHere's one case that is tricky to get right in c++. At the moment you can call sort(x,y) to sort a range, or sort(x,y,z) to give a comparator. If we allow sort(c) for a container, is sort(c,z) sorting a container with comparator, or a range? It's surprisingly hard to get this right with templates, without concepts.
- mehrdadn 8y agoDo ranges and iterators and comparators even have conflicting requirements? I feel like an object could be all three, in which case it'd be ambiguous what was intended.
- plorkyeran 8y agoNo, there's nothing (other than good taste) which stops you from passing a pair of arguments to std::sort() which would be legal for both std::sort(begin, end) and std::sort(range, comparator).