Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Ranges is one of the few things in 20 that I really like - not having to do begin()/end() madness for stuff like sort, transform etc means you aren't thinking about the _how_ and can spend more time focusing on the _why_. It starts to feel like Unix command line with pipes, finally I can chain together the components I want without making tons of unreadable of intermediaries, and potentially without even any allocations if I play my cards right. I can also safely do transforms on vectors where intermediaries would require lots of memory, which would have meant "one big stonking for-loop" before. Ranges are amazing and I'm really annoyed clang is dragging its heels with proper support.


It’s all fun and games until you actually use it in a non-trivial scale and you experience compilation times go through the roof. (Your Debug builds will also be really slow.) It’s just not a good feature to use in the current state of C++.

https://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/


Interesting read. It seems to me here that they're trying to shoehorn ranges into coroutines though - yes it technically works, but it's not pretty or performant.

If you have genuine data transformation tasks then I think ranges make a lot of sense. The kind of things that would be a 1-liner in Unix command line:

  cat foo.txt | grep "bar" | cut -d "," -f 3 | sort | unique | wc -l
This can be expressed really nicely with ranges in a way that wasn't possible, or at least readable, before. If you want to use ranges to reimplement coroutines then of course it will be slow and ugly.

As usual with new features, they shouldn't be used everywhere, even if they could. I do agree with the complaints on the massive size though - I feel it could be implemented quite simply if they only wanted 80% of the features.


Just wanted to add that the linked piece is a really well articulated criticism of c++. I say that as someone who has been using c++ for about 30 years.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: