11 ms·
C++20 Design Is Complete: Modules, Coroutines in C++20
- ingve 8y agoMore info in Herb Sutter's Winter ISO C++ standards meeting (Kona) trip report: https://herbsutter.com/2019/02/23/trip-report-winter-iso-c-standards-meeting-kona/ https://herbsutter.com/2019/02/23/trip-report-winter-iso-c-s...
- mattnewport 8y agoI was happy to see coroutines make it in but some of the concerns raised about the design seemed to have valid points. I'll be interested to read the papers mentioned when they're available to see how a consensus was reached and what the plans for the future are.
- gpderetta 8y agoThere were at least 4 different competing coroutine proposal at the last mailing. I guess the committee didn't see any hope and convergence and just opted for the more mature proposal.
- yingw787 8y agoWonderful news! I don't use C++, but I appreciate how at the end of the day, C++ will always be with us, and so will its benchmarks/expectations, battle-tested tooling ecosystem, and generously bestowed developer power. Makes the rest of us strive that much harder :)
- ilovecaching 8y agoI'm not. Just like I'm ok with VHS and scan lines becoming niche markets, we need to push forward in programming language design. We've come a long way in the past 35 years; lessons have been learned, the field of programming language theory has progressed, and we're ready to iterate. C++ has been retrofitted, but like Java, it's commitment to backwards compatibility has ballooned complexity to an unsustainable point, and there are simply too many things that will never be fixed, and C compatibility will never be dropped. We need to forge forward, and support the next generation of programming languages.
- risaacs99 8y agoWell that's just like, your opinion, man. In all seriousness, C and C++ are with us forever. Improving and moving these languages forward, and improving their safety with static and runtime analysis (and hardware support) has to be part of the plan moving forward.
- ilovecaching 8y agoTo me, that's a very bleak outlook, and as I already mentioned, retrofitting C++ will never solve all of these issues; retrofits are always additive, and simply increase the complexity of the compiler and specification to the point that very few people actually understand the majority of C++'s semantics. Retrofitting also doesn't solve the philosophy of a language. There are simply aspects of C++ that are too vital to its identity to change. Is object oriented programming the final word on abstraction in programming? Probably not. This is a young field, and there are always better solutions lurking around the corner. When we buy into the notion that something should live forever, we rob ourselves of the opportunity to move forward, or to at least know with certainty whether something is truly the best. Unless we want to repeat what has happened with COBOL, where the systems have lasted forever to the point that all of the COBOL programmers are dead or retired, we need to start evolving our philosophy to favor language replace-ability, or stop guaranteeing backwards compatibility. The latter is untenable to most businesses, while the former can be achieved through the use of small services, FFIs, RPC, and system modularity.
- 7e 8y agoC++ does remove deprecated features, but so far there has been no reason to deprecate OOP. The fundamentalist viewpoint you're espousing is not particularly convincing; in particular, the amount of labor required to kill and replace working systems for aesthetic reasons (as opposed to evolving them) would remove much of the free time required to create new and innovative technology.
- ilovecaching 8y ago
- pjmlp 8y agoI am with you. As managed languages dev, I seldom use C++, but when I do it is the best system language currently available regarding tooling, libraries and hardware support (NVidia now makes GPGPU optimized for C++ semantics). For app development, there aren't many scenarios where C++ is really necessary, whereas for systems it is going to stay around for years to come. So anything that helps improving the quality of GCC, LLVM, CUDA, UWP, Metal Shaders, DirectX, Unreal/Unity/CryEngine/Cocos/Godot is more than welcome. For anything else, we can just follow Microsoft's security suggestions as presented at Blue Hat IL, namely C# (replace by favourite managed language), Rust and modern C++. https://github.com/Microsoft/MSRC-Security-Research/blob/master/presentations/2019_02_BlueHatIL/2019_01%20-%20BlueHatIL%20-%20Trends%2C%20challenge%2C%20and%20shifts%20in%20software%20vulnerability%20mitigation.pdf https://github.com/Microsoft/MSRC-Security-Research/blob/mas...
- DSingularity 8y agoHow is gpgpu optimized for c++ by nvidia?
- jcelerier 8y agohttps://devblogs.nvidia.com/cuda-turing-new-gpu-compute-possibilities/ https://devblogs.nvidia.com/cuda-turing-new-gpu-compute-poss...
- pjmlp 8y agoSince Volta, NVidia GPUs are designed taking into account C++'s semantics. http://cppcast.com/2017/09/olivier-giroux/ http://cppcast.com/2017/09/olivier-giroux/ https://m.youtube.com/watch?v=86seb-iZCnI https://m.youtube.com/watch?v=86seb-iZCnI
- eggy 8y agoOr follow NVidia's security pick - SPARK, a subset of Ada [1] for their autonomous driving and automotive firmware software. [1] https://blogs.nvidia.com/blog/2019/02/05/adacore-secure-autonomous-driving/ https://blogs.nvidia.com/blog/2019/02/05/adacore-secure-auto...
- opdroid1234 8y agoReleasing new standards of such a memory unsafe language in 2019 is an irresponsible act. C++ committee should be working to move C++ users to safe languages like Rust.
- yodon 8y agoThe surface area of C++ 17 is so huge it's already largely a write only language (impossible for a normal maintenance programmer to have learned and mastered all the syntaxes and idioms). I'm not looking forward to trying to maintain a C++ 20 codebase that a bunch of architecture astronaut devs went wild on.
- saagarjha 8y ago> The surface area of C++ 17 is so huge it's already largely a write only language You don’t necessarily have to use every C++17 feature…
- corysama 8y agoAnd, a whole lot of the new features are there to replace difficult and verbose common uses of old features.
- Gibbon1 8y agoYou can't rewrite all the code you come in contact with.
- jarfil 8y agoThat's only true when writing new code. When you have to maintain code, you need to use all the features used by any one of the people who've ever worked on it, which at some point becomes all of the features.
- jhayward 8y agoWhen reading/reviewing someone else's code you have to know the entire set of problems and constraints that may arise from their code, including syntax traps, semantic esoterica, and effects. You can't simply decide on a subset of the language that you like and declare than none of the rest of it affects the code unless you want to trust that none of the excluded set has any impact.
- beached_whale 8y agoThat is a conversation with who you work with. You don’t use all the tools in the garage but are really happy they are there when you need them. Also, a large part of modern c++ is that simplicity is not only better for people but for compilers.
- an_opabinia 8y agoI have mixed feelings. On the one hand, C++ has created generations of Visual Studio GUI addicts. Imagine how much further software would have advanced by now if the average person (a Windows user on a crappy laptop) had good, free tools to make web and mobile applications. Two things VS and C++ are just really bad for, if you inhabit reality. And all those stubborn people who are going to reply insisting otherwise, how much better would the world be without them? Just kidding guys, hang in there. On the other hand, less competition! Long live C++!
- altairiumblue 8y agoAs someone who doesn't use C++, can anyone explain in a straightforward way why a low level language is going through so many new versions? And is there big difference between the latest version and C++ from 5 or 15 years ago? How do you guys keep up when a huge language is continually changing?
- inopinatus 8y agoApplications programmer: In a low-level language like C++... Chip designer: In a high-level language like C++...
- aDfbrtVt 8y agoIt's called High Level Synthesis for a reason :)
- colanderman 8y agoC++ isn't really low level. The changes are usually in libraries, not in the language itself. C++20 is by far the largest change language-wise since C++11. To answer your question, one of the motivations behind the (ongoing) design of C++ is to factor out and codify common C/C++ coding idioms. Almost every feature, library or language, can be traced back to this motive. So most "new" features are less so "new" and more so "that thing you're doing informally? It's formalized now." E.g. concepts codify how template parameter requirements have traditionally been stated.
- nicoburns 8y agoC++ includes low-level and high level features.
- stefan_ 8y agoIt's not low-level, it's a perfectly modern high-level language. But as with anything C++, you and your team need to decide on a per-project basis on how far down the rabbit hole you are willing to go. There is a world of difference between C with classes and metaprogramming parser generators. And to the standards credit, a lot of the new stuff can be used individually.
- devwastaken 8y agoI've been fighting c++ recently with qt. Something as simple as iterating over widgets on a page isn't possible without casting to every kind of child widget and checking it. I get why, it's because if static typing, but I wonder if it'd ever be possible to 'type hint' and make it possible to implicitly downcast. For example qt will let you iterate over QWidget * type, but you gotta cast it to the real type of QLineEdit and such to get the widgets values. Of course the 'c++' way is doing event listeners and recording data when it's changed.
- llukas 8y agoThere is another way: https://sourcemaking.com/design_patterns/visitor https://sourcemaking.com/design_patterns/visitor
- ahartmetz 8y agoA tangent on ways to do it with Qt, because I don't like seeing Qt presented in a bad light due to unfamiliarity. With Qt you can chain QObject::metaType(), QMetaObject::className(), int QMetaType::type(const char *typeName) to get an integer you can use to switch () on type. It is, I believe, possible but obscure on purpose because it is not meant to be used willy-nilly. You can also access Q_PROPERTYs by name using QObject::property(), and Qt's own classes have the same names for the same properties where it makes sense - such as text() in QLineEdit and QAbstractSpinBox etc. It depends on your requirements if using that approach actually makes sense. I haven't seen it used yet... If you want to serialize GUI state, a more intrusive design where, say, you keep some helper data on the side to allow "dumber" code in the actual de/serialization might be better. Or just wire up the widgets to a model (QAbstractItemModel and / or QObjects exposing Q_PROPERTYs - that's how you do it with QML if you do it right) and use the model as the main source of truth and, of course, for serialization. The "high level debugger for Qt" GammaRay is a nice showcase of what you can do with Qt's introspection capabilities. Qt had ~3 extension points added for GammaRay to observe object lifecycles, most everything else is based on pre-existing functionality.
- devwastaken 8y agoHow do you use QMetaType::type without having to do the same as I said, which is explicit casting? afaik there's no way to get the 'real' type that you can shove into qobject_cast or dynamic_cast to turn QWidget into a QLineEdit. The only way is to write in the type and try each cast, you can't store types in some map and go 'get' the type at runtime to have casted.
- Jerry2 8y agoSince the language is shifting and changing so fast, how do teams pick style guides and coding standards for multi-year projects?
- bad_alloc 8y agoIn my experience you stick with a certain version, even as new stuff comes up. My current work is in C++14 and will not move to newer versions.
- therockhead 8y agoWhat are the reasons for not moving? We are currently on C++ 17 and we need to support Windows, macOS,iOS and android.
- gmueckl 8y agoOne reason: consistency. When you introduce new features, idioms shift and maintaining code that uses multiple idioms for similar purposes is simply less fun. In the worst case you make changes harder because you now have to make your changes compatible with more modes of usage.
- ryl00 8y agoAn IT department that controls compiler upgrades, in my case :/. We're still stuck on not-quite-C++11 because we're still stuck on g++-4.3
- gpderetta 8y agoDependency (sometimes even binary dependency) with a library that doesn't support newer standard can be an issue. Not all compilers guarantee interoperability, and even with those that do there can be bugs.
- gpderetta 8y agoNo plans to move ever, or just sticking to it for a while? The latter is perfectly reasonable, the former seems a great way to end up with technical debt: at some point compilers might (although it is admittedly very unlikely at least for gcc) drop support for older standards, 3rd party libraries as well(this is much more likely).
- rienbdj 8y agoVery disappointed that coroutines will be included in their present form. Did the committee just want to push something out?
- smallstepforman 8y agoA good solution today is better than a potentially better solution tomorrow.
- jcelerier 8y agoit really depends. if the accepted coroutines hides memory allocations willy-nilly, it means that there is a whole body of code that will never ever use coroutines in their code. While waiting for non-magic-allocating coroutines would have made those better in five years.
- mattnewport 8y ago"Coroutines (Gor Nishanov) was adopted for C++20. A number of other authors that have their own coroutine proposals have also done great work to give feedback to this design and inform the committee in the process of showing their own designs, and the adopted coroutines design is expected to adopt some of their additional programming capabilities in the future as well as we continue to build on it after C++20. At this meeting, we had many detailed design discussions, including notably these papers that will be available in a few weeks when the post-meeting mailing is posted: a unified consensus report from all coroutines proposers describing the strengths and weaknesses of all their proposals, and a consensus report from implementers from all major C++ compilers about the tradeoffs and feasibility of the basic facilities required by the various coroutines proposals. Both of these papers are very educational and highly recommended." https://herbsutter.com/2019/02/23/trip-report-winter-iso-c-standards-meeting-kona/ https://herbsutter.com/2019/02/23/trip-report-winter-iso-c-s... The papers aren't available yet but presumably will explain the reasoning behind accepting them in their current form.
- alexeiz 8y agoIf you want your opinion heard, you have to participate. The problem though, is that certain people have pretty much a full-time job to push stuff through the committee. So they invest way more time than you can ever afford. And in the end they get their shit into the Standard.
- waynecochran 8y agoI am still trying to understand when T&& is a r-value and when it isn't. https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers https://isocpp.org/blog/2012/11/universal-references-in-c11-... I feel I will never master C++ -- neither will Stroustrap. https://www.theregister.co.uk/2018/06/18/bjarne_stroustrup_c_plus_plus/ https://www.theregister.co.uk/2018/06/18/bjarne_stroustrup_c...
- CJefferson 8y agoI used to be on the c++ committee and contributed to both gcc and clang. That T&& r-value mess, along with c++ still having no built in method to print a vector, are the straws which persuaded me to abandon c++. It seems designed to be confusing.
- Something1234 8y ago> c++ still having no built in method to print a vector This a thousand times. All the best languages have a good way to print out a structure, and allow interactive inspection. Instead with C and C++ we have to suffer with debuggers rather than just using good old print statements.
- pjmlp 8y agoEnjoying the productivity of debuggers since mid-90's, with ability to graphically display data structures. Printf debbuging is the actual suffering.
- jstimpfle 8y agoYou think that print debugging is wrong and debuggers are the way to go?
- atq2119 8y agoYes. There is a time and space for print debugging or its equivalents, like when debugging very low level code, or when debugging rarely occurring problems. However, using a real debugger is extremely powerful when it's available.
- sagartewari01 8y agoC++ is no longer C++. It might have been that at some point, but nowadays, it's more like C plus e'th root of pi.
- adzm 8y agoC*=C
- waynecochran 8y agoEven the name "C++” is inane. I have a love / hate relationship with C++ — without the love.
- azhenley 8y agoAfter working with Go for the last few months, looking at these C++20 examples just baffles me. So many symbols, keywords, and library calls. It really makes me miss C. I wonder how long it would take to learn C++ now.
- ilovecaching 8y agoGive Rust a try. People like to complain about the Rust learning curve, but comparative to the language it's trying to replace (C++) it's actually quite simple and the compiler/tooling will hold your hand compared to the conventions you have to memorize to use C++17 safely.
- banachtarski 8y agoNot OP but i keep trying and the tools still have a long way to go and compile times are abysmal (even relative to C++). For example, https://github.com/rust-lang/rls-vscode/issues/237 https://github.com/rust-lang/rls-vscode/issues/237 this issue that has persisted for over a year with no signs of being fixed. With C++, in spite of its warts, I can still be productive just because of the ecosystem around it. Rust was something I was gung-ho about, but after repeated attempts to create a medium/large project, I am still in a wait and see mode. Moreover, it's just not powerful enough. Many features are coming in, but they break the compiler and you end up needing to work off nightly regardless. I think it's a good effort, but people just recommending the Rust train nonchalantly really need to step back and check their biases.
- ilovecaching 8y agoI don't think using a vscode plugin as an example of Rust not being ready is very fair. You could always fix the issue yourself, it is open source you know. My original point was that we shouldn't be building monolithic projects in a single language, but if there is an absolute requirement for it, Rust compile times aren't that bad. C++ also has very long compile times, it just comes with the territory. The reason Go can compile in under a second is because they purposefully keep the language specification simplistically small. I'm not recommending Rust nonchalantly. I write rust every day professionally, and I basis my opinions on the experiences I've had with it in that environment.
- waynecochran 8y agoC++ compiler authors must practically be gods to translate this stuff. There are so many parsing problems — quantum mechanics is child's play.
- abhishekjha 8y agoQuery: Would the compiler writers have to write compilers from scratch for C++20 or the features can be added without overwriting the entire system? I am aware that new features means a few parts needs be rectified. But does the whole need to change? And I agree for C++ compiler writers to be gods. Looking at the source code for GCC/clang makes me doubt my programming skills. Same goes for the linux kernel source code.
- lallysingh 8y agoIt's the parser (context dependent) that's hard. The rest is a regular compiler that you can learn to write out of a textbook. And the parser is hard in pain-in-the-ass terms, not CS theory terms. https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/cp/parser.c https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/...
- bsenftner 8y agoIf the parser is hard to write, that means the syntax is conditional upon previous statements, which I've not seen in the spec. As long as the syntax is Lexical, no real issues parsing. How does the context throw curves?
- demurgos 8y agoThe example I know is the following line: foo * bar; This is either an expression statement computing the product of `foo` and `bar` or the declaration of a variable `bar` as a `foo` pointer. To solve this ambiguity, you need context: if `foo` is a type available in the current scope then it's a variable declaration, otherwise an expression.
- 8y ago
- NotANaN 8y agoThe fact that C++ versioning uses two digits for the year is the most 1980s thing about it.
- cpeterso 8y agoIf C++ continues to release a new version every 3 years, 2098 will be C++98 again. So either the language designers don't think C++ will survive to 2098 or they will need to change their versioning.
- atombender 8y agoAnyone know how the modules problems were resolved? There were rumblings that the technical challenges around build systems and dependency resolution were blocking items (e.g. as explained here [1]). [1] https://build2.org/article/cxx-modules-misconceptions.xhtml#build https://build2.org/article/cxx-modules-misconceptions.xhtml#...
- lossolo 8y agoYou can read about it here: https://www.reddit.com/r/cpp/comments/au0c4x/201902_kona_iso_c_committee_trip_report_c20/eh4rg0m https://www.reddit.com/r/cpp/comments/au0c4x/201902_kona_iso...
- cmrdporcupine 8y ago"TL;DR: C++20 may well be as big a release as C++11." I feel like with the addition of modules this may be a release of the language spec that is going to need at least a decade to settle in. I hope the next few changes are more incremental. I am very excited for modules. Hell, maybe I'll even see them used some day in the chromium code base I work in.
- sigmaml 8y agoOpened the coroutines draft just now. I like the humour in the note at the bottom of Page 1!
- pjmlp 8y agoModules are in! Great news.
- deleted 8y ago[deleted]
- FrankDixon 8y agoI wonder if this really makes sense. In the long run, C++ will be even more massive than it is now. A hundred ways to do sth. Meanwhile, new, lean, langs jump up all the time: crystal, nim, swift, rust. I wonder how long the momentum can carry C++
- sprash 8y agoC++ will never die because it is the only language that really owns the "zero cost abstraction" business like no other language.
- chombier 8y agoSo most notable new language features are modules, coroutines, concepts and contracts. That's huge! I remember vaguely that there were some issues with the initial module proposal and multiple (concurrent :) coroutine designs. Does anyone know what the problems were and how they were resolved?
- denart2203 8y agoThis is super exciting! Big congratulations! I only wish that C++20 gets a wide adoption as quickly as possible once its released.
- sprash 8y agoYay, even more features and complexity. Will they ever stop? It already takes years to really master C++. Soon you will be unable to read and understand C++ code without googling every second line.
- mruts 8y agoI consider myself an expert on C and I always used to put C/C++ on my resume. But it occurs to my that C and C++ aren’t really similar anymore and that I don’t really know C++ at this point. I’ve always despised C++ but that’s when it was pretty similar to C. It seems to have gotten exponentially more complicated but also it seems like it’s pretty expressive at this point: potentially supporting Rust-like safety and FP-like design. Maybe someone who’s an expert can tell me how different C++20 is from C?
- IshKebab 8y agoVery very different. Don't put C/C++ on your CV if you don't know C++. You'll just annoy employers who are looking for C++ developers.