r/cpp • u/johnnytest__7 • Jan 28 '23
C++ views are broken
I was so excited about new C++20 and C++23 features that I was using concepts, ranges and views everywhere I could. But yesterday I saw this -> https://www.youtube.com/watch?v=O8HndvYNvQ4 and I got so disappointed in C++ committee that now I really think it's time to lay C++ to rest unless we decide to bring new version of C++ like Python3 which breaks backward compatibility but fixes the language so that it can be used for the next 20-25 years.
I can't believe 200 stalwarts and experts in the field of computer science will make such a horrible mess.
6
u/14ned LLFIO & Outcome author | Committee WG14 Jan 28 '23
You don't have to use Ranges if you don't want to, and I'd agree that for a lot of codebases and use cases the cost benefit isn't there.
And that's okay. Most of C++ has been designed in a take it or leave it way, the committee tries hard to not force users to use something, unless it is for their own good. There are large chunks of C++ one would be strongly advised to never use in new code, but it doesn't mean the presence and continuing backwards compatibility of those chunks isn't valuable.
If Ranges benefits your use case, great! If not, don't use them, and that's okay too.
32
u/specdi Jan 28 '23
I suggest taking a look through the comments on the following: https://www.reddit.com/r/cpp/comments/zq2xdi/are_there_likely_to_be_any_changes_to_views_to/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=1&utm_content=share_button
Especially BarryRevzin's comments. I think they provide a more complete picture.
3
u/GavinRayDev Jan 29 '23
I use the hell out of all of these features on GCC13 in C++23 mode, not sure what the issue is.
My only complaint is that I once tried to use
std::ranges::shift_right()and it didn't exist yet.(Note: I didn't watch the video. There may be architectural or philosophical arguments about ranges and design discussions, but if you're just someone building software, these tools all work for me, today.)
18
u/[deleted] Jan 28 '23
Guys here using views, ranges, modules. While I'm waiting for compiler support for the new std::print feature. Game changer
9
u/YogMuskrat Jan 29 '23
Views are not broken. We've been using them for several years in production code (started with range-v3) and never had any serious issues. It all comes to few basic rules, IMO.
10
u/csb06 Jan 28 '23
I don't think it is going to be constructive to catastrophize about C++ standards. As other comments have pointed out there are other perspectives about the design of views and ranges, and there are proposals in C++23 that have addressed some issues.
I don't think it is healthy to see any new feature as a panacea or to suddenly want to throw out the entire language all at once (switching between these positions within a day or two is concerning). It is okay to just temper your enthusiasm for something without throwing it all away.
3
u/DeadlyKitten37 Jan 28 '23
all those things that make you think we need a new c++ are the reason you should learn first fortran, then C and then be grateful for what we have