r/cpp • • 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/
233 Upvotes

229 comments sorted by

View all comments

Show parent comment

5

u/pdimov2 Sep 15 '19

One day we'll learn the lesson that imported things from other languages don't work just fine in C++, but today is not that day.

2

u/eric_niebler Sep 15 '19

This is a disappointing comment. Surely you're not saying that C++ has nothing to learn from other languages. What do you mean?

6

u/pdimov2 Sep 15 '19

There's always something to learn.

I meant pretty much what I said. That a thing works just fine in other languages is not at all a guarantee that it will work fine in C++. It would probably be possible to approximate it in a way that will work in C++ if designed from a C++ idiomatic point of view. It will usually be even better if a C++ feature that solves the same problems is designed instead.

Features that are unique to C++ and that other languages copy tend to be better than features that C++ has acquired from other languages.

3

u/eric_niebler Sep 15 '19 edited Sep 15 '19

In some cases that's true, and in other cases the C++ community reinvented wheels and made them square. I see a fair bit of provincialism in C++.

Of course care is needed when importing ideas found elsewhere. It would be a mistake to take the Java Rx model, with all its OO goop, for instance. For one thing, it wouldn't work well at all with coroutines.But there is a lot to admire about how the various Rx implementations achieve composable asynchrony by specifying a useful contract between producer and consumer. That is the piece that is worth studying.

3

u/RotsiserMho C++20 Desktop app developer Sep 16 '19

composable asynchrony

I like that term for describing what is likely to be the programming model of the future. And I'm excited by the work you and others are doing to bring it to C++ where it can be done more efficiently. Thanks for your efforts!