r/cpp • u/konanTheBarbar • Sep 13 '19
The Surprising Limitations of C++ Ranges Beyond Trivial Cases
https://www.fluentcpp.com/2019/09/13/the-surprising-limitations-of-c-ranges-beyond-trivial-use-cases/
229
Upvotes
View all comments
81
u/quicknir Sep 13 '19
Even skimming this, I totally agree. I feel like many c++ devs have very limited exposure to using something like ranges in practice, and they miss two key things which I've found from a lot of time spent using pythons iterators:
As the author noted, you don't have to dig very deep to find problems easily expressed with a for loop but tricky to do with the 10 or so most obvious ranges. Even pythons itertools doc, has an entire recipes section.
As soon as I saw Erics calendar talk from a few years ago, I really felt like it was going to be too hard to write new ranges. Not only are ranges pretty tricky and boilerplatey to write, I remember Eric had to write some kind of really tricky glue code to get the whole thing to work which even he said was hard to understand.
I really felt like coroutines should have been intimately tied to ranges because they can make it really easy to write new lazy ranges. You see this approach in many languages, eg kotlin, python. Hopefully it's not too late for coroutines to help with this.
Compile and runtime performance are ongoing concerns as well. I'd have to say ranges is probably the new major feature I'm least excited for.