50 ms·
C++ Coroutines Do Not Spark Joy
- Charles78 5y agoThanks for the information, I will try to figure it out for more. Keep sharing such informative post. https://www.skylightpaycard.online/ https://www.skylightpaycard.online/
- wfsch 5y agoI am very surprised how complicated C++ is becoming in every revision. It began with a simple goal of adding classes to C. The STL, inline functions, "true constants" were all nice stuff. C++11 introduced nice stuff like "auto", constexpr. But now the new features are increasing the complexity so much that it is becoming harder to learn the language. Is so much complexity worth? How can someone new to programming ever hope to learn this monstrosity?
- matheusmoreira 5y agoBecoming harder? Last time I wrote C++ was in 2010 or so. There's so much new stuff I already consider it impossible to learn. It will become even more complex with this update.
- 72deluxe 5y agoRead Stroustrup's blue book written after C++11 was released. Not only is the font nicer than the white 2003 edition, it goes into sufficient detail to understand the new (now old!) features of C++11. I couldn't imagine writing C++2003 any more.
- TillE 5y agoI think it's not a coincidence that 99% of the complaints about modern C++ on HN are from people who...don't use C++. You don't get anything remotely like this tone of discussion on r/cpp or whatever. I've been continuously employed as primarily a C++ developer since around 2001. The language was pretty bad back then, but it's been getting better and better since C++11. The vast majority of the new stuff is absolutely wonderful to use, a huge improvement in productivity and code readability.
- deleted 5y ago[deleted]
- tralarpa 5y agoCould you explain what kind of projects nowadays use C++? I'm not up to date at all anymore. Used a lot of C++ until about 2010 (for simulations and Windows programming).
- sseagull 5y agoStill used a lot in scientific programming. Especially with long-lived projects, but even now new C++ projects start up. It’s a combination of institutional knowledge, domain-specific libraries, and low-level, hpc capabilities that keep C++ being used. (C++ for low-level stuff, python for the glue is a common paradigm in scientific computing)
- KineticLensman 5y agoGame development using Unreal Engine, which has a C++ API [0] [0] https://www.unrealengine.com/en-US/features/c-api https://www.unrealengine.com/en-US/features/c-api
- throw_m239339 5y ago> Could you explain what kind of projects nowadays use C++? I'm not up to date at all anymore. Used a lot of C++ until about 2010 (for simulations and Windows programming). All browsers you use are written in C++ (Firefox, Chrome...). Node.js is written in C++. We live in that bizarre world, where on one side we have C, an antiquated and simplistic language and on the other C++ a monster of complexity that provides also basic modern stuff C will never have. Rust has complexity of its own but it's more like a "philosophical" complexity rather than syntactic. A lot of C and C++ developers just don't like how Rust works.
- jandrewrogers 5y agoHigh-performance database engines and similar data infrastructure are almost exclusively written in modern C++ these days. They benefit immensely from new C++ features.
- TinkersW 5y agoYou could learn the stuff added since 2010 in like a couple days if you had a solid understanding of C++98, it really isn't that hard.
- gsliepen 5y agoThis article discusses things that are totally irrelevant to someone who will actually use coroutines, because they will use https://github.com/lewissbaker/cppcoro https://github.com/lewissbaker/cppcoro or wait for C++23 to give them the library support for coroutines, which will make usage simple, like the first code snippet from the article.
- gpderetta 5y agoThe unreliable allocation elision is very relevant for most coroutine users. edit: also the lack of composability is relevant.
- gsliepen 5y agoIt is possible to compose them more easily than described in the article; Lewis Baker's cppcoro library for example provides a recursive_generator<> type[0] that allows this without using any macros. It's up to the library part of coroutines to make things easy, end users are not expected to write low-level coroutine code themselves. I wonder about the allocation elision. Return value optimization became mandatory, and some compilers can already elide calls to new/delete and malloc()/free() in normal code, so perhaps it will be possible to guarantee allocation elision in the future in the most used cases. [0]: https://github.com/lewissbaker/cppcoro#recursive_generatort https://github.com/lewissbaker/cppcoro#recursive_generatort
- jerrre 5y agoI do agree that C++ is a very big and complicated (and ugly) language, and because they value backwards compatibilty the only way it can go is even more complicated, because the cannot strip out stuff. But you last question can be answered in a couple of directions: 1. you don't HAVE to use C++, if there's another language easier, or better suited to your goals, use that. I think as long as C++ is the best choice for some domains it will stay relevant. 2. you don't HAVE to know/use all features of C++. If you're working solo just ignore the parts you want. If you're in a big team hopefully the codebase is such that you don't need to know everything about it to be productive. 3. Is adding features worth it? Well if you take 1 & 2 in to account, I think the downsides are capped a bit, and the upside is: more options. But of course whether you prefer many options with a lot of complexity, or a straightforward language is subjective.
- physicsguy 5y ago> the only way it can go is even more complicated, because the cannot strip out stuff. The irony is of course that they have stripped stuff out. I spent a fair amount of time going through an old code base in my last job stripping out std::unary_function and std::binary_function. Not saying that the replacement isn't better however.
- LadyCailin 5y agoIt’s actually fairly rare that you get to choose what language and language features are used in the code base that you’re responsible for. Sure, if you’re the tech lead at a startup, or working on a personal project, but for all my day jobs, I’ve not once gotten to choose anything that fundamental about the code base. So just in general, I do think it’s fair criticism of a language for offering crappy features, even if it is “optional” to use them. (Not arguing either way for coroutines specifically, as I’m not a c++ dev).
- joeberon 5y agoUnfortunately the C++ standards process is completely out of control and driving the language to total chaos
- gpderetta 5y agoCould we please keep the conversation on (the coroutine) topic for once instead of degenerating into the usual C++ bashing?
- farresito 5y agoI think it's therapeutic for those that have to deal with C++ on a daily basis haha.
- MauranKilom 5y agoI don't think so. The complaints always seem to come from people who parted ways with C++ a long time ago. Given that C++ remains popular, it feels like some are unsure whether it was the right choice and they need to publicly self-justify it.
- yakubin 5y agoWhat do you base that on? Just because someone chooses other languages whenever they can, doesn't mean they're not forced to use C++ at work.
- kllrnohj 5y agoMany of the complaints about C++ really don't line up with day to day experiences using C++ IMO. They focus on problems and complexities that just don't come up often if at all unless you're really going into the weeds of implementating your own "STL-like" types. It'd be like if every time Java is mentioned everyone just bashes how terrible JNI's API is. Yes, it is bad. It's frankly horrifying. But it's also basically 0% of where you spend your time when writing Java on the daily. That's not to say C++ is rosey in practice, just the problems that actually get encountered on a modern code base almost never get mentioned here while all these esoteric edge cases that never come up in practice are beaten to death. For example take C++ templates. In this thread they are slammed repeatedly. In practice you know what? They're fine. It's not that bad. Template metaprogramming is brain bending and hard, and I wouldn't suggest it. But basic templated classes or functions? No harder or more complex than the exact same thing in Java or C#. And in practice that's really all you do the overwhelming majority of the time.
- mFixman 5y agoMy least favourite example of bad C++ change is deprecating and removing the overload of `std::random_shuffle` that doesn't require a new random device and a random function [1]. Sure, that version was cryptographically insecure, but 95% of the use cases of shuffling have nothing to do with cryptography and don't need to be secured. This is not a case like PHP's `mysql_query` which has an easy replacement: now you must declare an `std::random_device` and `std::mt19937` and pass them to your functions. This nearly made me fail a job interview in an embarrassing way. [1] https://en.cppreference.com/w/cpp/algorithm/random_shuffle https://en.cppreference.com/w/cpp/algorithm/random_shuffle
- steerablesafe 5y agoApart from not being very random, it also wasn't thread-safe.
- physicsguy 5y agoI think of the C++11 RNG stuff is thread safe, you need to lock around it or have an RNG per thread.
- gpderetta 5y agoThere were three competing coroutines designs in front of the standard committee: stackful coroutines, from boost; C#-like stackless coroutines from MS; and zero-overhead stackless coroutines initially from chriskohlhoff (but then picked up by many others). After a lot of back and forward, the committee decided to pick the most proposal (i.e. the MS one) with the most complete implementation and potentially less ambitious. These are both good good features, but we ended up with a very complex, hard to use, design that requires unspecified compiler magic to remove all overhead. Interestingly enough the committee went in the opposite direction for networking recently rejection the battle tested ASIO, again from chriskohlhoff, for a yet unproven design initially from Facebook, now Nvidia. edit: personally I'm a huge fan of stackfull coroutines, but I could have lived with zero overhead stackless coroutines. The current design is IMHO the worst solution. Then again, sometimes it is better to ship something than argue forever.
- otabdeveloper4 5y agoASIO is a horrible godawful mess, in this I agree with them.
- gpderetta 5y agoI doubt you will like S/R then.
- inetknght 5y agoI disagree. ASIO has been (mostly) intuitive for me to use. The hardest part is that it doesn't have great documentation and that it sometimes changes paradigms (eg, the recent change in executors has been super annoying and lead to problems in migrations). But of course it really depends on how you think when you write software. If you don't really think asynchronously then you're going to have trouble.
- gpderetta 5y agoAny supposedly high performance async abstraction is almost necessarily going to be complex and flexible otherwise people will keep using the low level system API.
- spyremeown 5y agoC++ has already got to a point the teams inside my company can't even talk between themselves properly (it's R&D and very heterogeneous, so not that bad) but this doesn't happen with any other language. It's ridiculous. The newcomers struggle so much to learn the language, and tbh I just say to them to learn the sane 5% of the language and ignore the rest. It's a monstrosity, extremely hard to bring up and generally not nice to read nor write. I really wish a good, well-maintained, modern (as in, actually break stupid compatibility, just fuck it. It's 2021 for God sakes) C++ existed.
- andi999 5y agoD tried, but somehow failed.
- zarzavat 5y agoD suffered from too many options, multiple standard libraries and indecision between GC and manual memory management.
- generichuman 5y ago> D suffered from [...] indecision between GC and manual memory management. It is still suffering from that. If you want to manage memory yourself you can't use some parts of the standard library + you can't use a lot of the community packages since they assume there is a GC present. So far it looks like the best alternative is Zig, but sadly it doesn't have some of the higher-level language features such as function overloading, compile-time interfaces (Rust traits) or macros. Jai seems to have most D features and more without the GC [0] but Zig is more likely win popular mindshare since it already is in the open + comes with a C/C++ compiler which is pretty cool. [0] https://github.com/Jai-Community/Jai-Community-Library/wiki https://github.com/Jai-Community/Jai-Community-Library/wiki
- andi999 5y agoExciting. The tutorial says download the compiler, somehow cannot find it, do you have a link?
- afarviral 5y agoWhy do people think its too hard to learn? I've been writing in it and learning the new stuff and I'm impressed. Is it just overchoice? Where is all this extra complexity I keep hearing about hiding? Seems to me to keep getting free DLCs that you can optionally learn. Its the language that keeps on giving. My main complaint is the verbosity of it, even with the new stuff which adds brevity like range-based loops. Can someone provide a cooherent example where it was too complex for their needs?
- zarkov99 5y agoHave you actually looked at the co-routine stuff? It is another level of awful, even for C++. The committee screwed that up.
- afarviral 5y agoNot yet, no. I will look out for it. I am definitely I'm in an early phase where I'm just finding things "cool", without noticing why they might be awful. But I do wonder if there are senior devs on each side of the this C++-is-awful fence?
- zarkov99 5y agoI have done C++ for 15 years, its the only choice in the HFT domain I used to work in. There is nothing that can replace it right now because of its performance, the quality of the compilers and the available library eco-system. But that does not mean that some of C++ corners are not inexcusably obtuse. Co-routines is a new one.
- otabdeveloper4 5y agoYou may think you need async, but you don't. This isn't Python or Javascript, the use case for C++ coroutines is microcontrollers and other things without a functioning modern OS.
- zarkov99 5y ago
- bborud 5y ago"Do you know how the Orcs first came into being? They were elves once, taken by the dark powers, tortured and mutilated. A ruined and terrible form of life."
- Guthur 5y agoIt seems like a fouls errand for C++ to continue to try and add higher level abstractions while maintaining a zero overhead principle.
- bruce343434 5y agoIt is. It is a well known public secret that the STL isn't all that efficient due to issues with e.g. iterator invalidation. You can crank out a hash table that supersedes std::unordered_map in pretty much every situation in a weekend. What C++ people need to realize is that they can't keep their cake and eat it too.
- gpderetta 5y agoThe single biggest contribution of the STL are not the data structures nor the algorithms. It is the design, the shared vocabulary and protocols. This is why I can replace almost any use of unordered_map with, say the corresponding abseil implementation with very little changes to the code. Stepanov has always seen the STL as a starting point, not a finished library.
- bruce343434 5y agoAny C++ code I have ever worked with is littered with `std::`. Replacing all that with `otherlib::` would be a herculean effort at best. You might be tempted to do a simple search and replace, but let's say there's also instances of `mystd::` (probably rare). Or perhaps you don't want _all_ `std::` to be replaced. Anyway, my point is that this whole ordeal gets hairy quickly. And in practice, I only ever see `std::`. And not only does it give off horrible noise in the code, in my mind I think "this data structure is probably not optimal". "This algorithm is probably not optimal".
- steerablesafe 5y agoMost data structures in a project are not performance bottlenecks, so that's alright. While there are much better hash table implementations, std::unordered_map is still usable, although not great.
- gambiting 5y agoI've been saying this for quite a while - new C++ features seem to be added by people who don't actually use the language for any real job, or who do but who wish they were using C# instead. I work in games development and the rate of adoption of new C++ features is incredibly slow. Only in the last couple of years it sort of became ok to use auto(although still frowned upon). Foreach loops are still out of the question though. I don't see the need for higher and higer and higher levels of abstraction in C++. If you need that then we just use C#.
- jcelerier 5y agoI mean, here is the tradeoff really bad ? The central point of this article is "c++ coroutines may allocate". Except Rust's, are there are a lot of languages where you can enforce that coroutines don't ? I'm confident that this is not the case for any JVM or .Net based-languages ; let's not even talk about Python or functional-ish languages. For me for instance, as bad as C++ coroutines may be, doing the same thing in C# than what I'd do in C++ is literally not even on the radar ; we just set a much higher bar for what is "good" in C++ which leads to a lot of depreciating-tone articles but one must not loose sight of the whole picture ; almost no coroutine implementation in the world sparks joy when the same criterion than this article uses is applied.
- gpderetta 5y agoAmen. As I said elsethread, what we got is better than nothing (and a huge amount of work was put in by Gor et al.). It is a shame we could have gotten much more.
- snovv_crash 5y agoC++ is trying to cater to every usecase. You don't need to use every feature, and if you move to a different field you may encounter different subsections of C++ usage. For example, C# doesn't run on 16bit microcontrollers, and many things in the language make it unsuitable for this. If you added this as another of the design constraints on C# then it would be more complicated for desktop application devs, or server devs. C++ handles all of these cases, so is necessarily more complex. IMO what C++ needs is compiler support for warnings when "old" bad practices are used, which would allow the language to remain flexible and backwards compatible, while still providing guidance for the future.
- zarkov99 5y agoIt is sad. Once again C++ is foisted with an overly complex and ugly standard that will make programmers unhappy for decades and likely cost billions in lost productivity. The proposal got pushback from a number of expert sources as well as from the community at large and yet here we are.
- AlexandrB 5y agoI wonder if this will go the way of std::auto_ptr and get replaced by a more sane version 10 years later.
- m0zg 5y agoGoogle needs to get off its ass and open source Fibers (not to be confused with Google Fiber). Fibers sparked plenty of joy in me back when I was at Google. It's just a more dignified way of doing things with threads, IMO. Here's the talk which, unfortunately, does not show the higher level APIs I'm talking about: https://www.youtube.com/watch?v=KXuZi9aeGTw https://www.youtube.com/watch?v=KXuZi9aeGTw. If this were released today everyone would slap their foreheads and say "of course that's how it should be done". Google folks have already removed the obstacle in that direction by adding userspace switching to the kernel in recent kernel releases. Just go all the way now, and release the kraken. Last update I've seen on this is this article from June of this year: https://www.phoronix.com/scan.php?page=news_item&px=Google-Fibers-Toward-Open https://www.phoronix.com/scan.php?page=news_item&px=Google-F... Imagine how excruciating it must have been to all the Google people on the C++ Standard committee to work on this stuff that comes nowhere close to what they've been using internally for years, and not be able to talk about it in any kind of detail.
- dilyevsky 5y agoFibers were seriously awesome, nice that userland preemption has been finally accepted upstream too. These days i just gave up on c++ and use Go
- m0zg 5y agoYeah, I also don't advise my clients to start new C++ projects and steer them towards either Go or Rust (most pick the former, since it's easy to learn). If I were to start a product today, I'd likely be using Rust myself, purely due to the fact that once I need to hire people the Rust compiler won't let them do stupid stuff with shared state. What Go and Rust taught me more than other languages is that there is value in _not_ providing certain capabilities, such as inheritance or (in Rust) the ability to unsafely modify shared state.
- saurik 5y agoI have been using C++ coroutines in all of my development work for the past two years, and I am "excited by them", FWIW; they have changed C++ so drastically for me that I have no longer felt the need to work with any other random scripting languages (such as Python, which I used to use extensively): their ergonomics are actually pretty awesome. Most of my projects, however, were things I would have been willing to develop in languages that would heap allocate constantly, so that heap allocations are happening here that I am poorly controlling isn't driving me insane (though I agree it sucks). (The argument about competition is just strange to me, as that's just how generators as an abstraction--in any language--work... if you want to be able to have a generator yield to a separate generator the way you do that is by first developing a flatmap function that takes a generator of generators and yields its elements.)
- ot 5y ago> I have no longer felt the need to work with any other random scripting languages Compile times are pretty bad though :) Especially with coroutines: at least clang (don't know other compilers) AFAIK works by copying the same function n times for each resumption point, and that's extremely slow.
- saurik 5y agocompetition -> composition yields its elements -> yields its element's elements
- banachtarski 5y agoCoroutines let you control where allocations go though? Just override operator new/delete on your promise types. Honestly the feature has been amazing and has cleaned up my code a ton. It’s not for average users. It’s for library writers who then build abstractions on it to make async code easier to write for others. Exposing the coroutine frame as a non opaque structure is simply not practical. Not a super well-informed article IMO.
- brandmeyer 5y ago> It’s not for average users. It’s for library writers Justifying the complexity of an interface by appeal to caste system is pretty poor, IMO. A very common methodology for solving big problems is to break them down into smaller problems, solve each one in turn, and compose them together. In other words, we use library-oriented programming. A productive feature in a programming language makes it easy to both create the library elements of the solution and to compose them together.
- banachtarski 5y agoThere are tons of facilities in the language intended for library authors and abstractions that are absolutely intended to be used out of the box. This is just how things are, features are provided at various levels of abstractions. I know HN loves to collectively hate on C++ but “caste system?” Lol
- cogman10 5y agoYeah, it's part of the charm of C++. The is almost horrifyingly modifiable. As a library author, that gives a lot of control over the functionalities of the abstractions you expose. For a day to day programmer, that sort of concern is (usually) overkill.
- shultays 5y agoI think "caste system" is the perfect word for it. I don't think it is a bad thing though, I am fine with having such castes in c++. First time I saw coroutines of c++ I was definitely like "yep, this is for library writers". I am not excited about it, but I am excited about libraries that will use it. It is similar how templated code that basically becomes "magic" for an average programmer like me. I can't wrap my head around such complex templated libraries either but the simplicity of using such libraries are sure welcomed by me. I think it is perfectly have some language features for more advanced users. Hey, at least they are adding concepts. Maybe I will move up to another caste and will be able to write more complex templated code now.
- pavlov 5y agoI think C++ coroutines is best understood not as something you'd use directly, but as plumbing that makes existing async libraries interoperable and easier to use. For example, Facebook's Folly has been updated to use coroutines and is being widely adopted at FB: https://github.com/facebook/folly/tree/main/folly/experimental/coro https://github.com/facebook/folly/tree/main/folly/experiment...
- cletus 5y agoThe snide response to this is does anything in C++ spark joy? More seriously, I've come to believe that most people shouldn't be writing multithreaded code. More specifically, if you ever find yourself instantiating a thread directly you've probably made a mistake. It's possible you're writing something sufficiently low-level or a library or framework that justifies that of course. From using Hack, I've come to really appreciate the single-threaded cooperative multitasking programming model for client code [1]. It's not unique to Hack obviously. Part of the power of C++ is the ability to allocate things on the stack or the heap. This is powerful but the complexity cost of this is so incredibly high that I honestly question if it's worth it. It's unsurprising to me to see the complexity that comes with coroutines as a result of this. [1]: https://docs.hhvm.com/hack/asynchronous-operations/introduction https://docs.hhvm.com/hack/asynchronous-operations/introduct...
- jeffbee 5y agoIs it that complicated? std::thread t([](){ std::cout << "thread function\n"; }); t.join(); With sane ground rules threading is not so hard. Don't try to use subtle atomics. Do use a mutex to protect all shared state. Do use scoped locks. Do use thread safety annotations.
- liuliu 5y agoThe difficulties of multi-threading code to me is not about crashes or protecting shared states or ownerships. It is about reasoning how it might interleaving between these protected critical sections. For these, mutexes / locks / atomics are the wrong level of abstractions to reason about on daily basis. I haven't used Structured Concurrency long enough to form an opinion whether that is the right level of abstraction or not.
- Jtsummers 5y agoStructured concurrency only partially helps. You still have to be aware of what state is being used and modified within the threads of execution so that you properly lock them. It does not remove the need for some equivalent to mutexes and locks unless each thread of execution is known to use and modify different pieces of state (like thread 0 modifies a[0], 1 modifies a[1], etc.). If there's any overlap you have to have a lock-equivalent that ensures the desired section of code runs atomically (relative to others using the same pieces of state). Or you need some kind of transaction system that can retry a stateful change.
- DonBarredora 5y agoC++ does not spark joy.
- gumby 5y agoI agree with most of the author’s reasoning and 100% of their recommendations. > As the coroutines are, I don’t quite know what they’re for. They seem like they might be useful, but nobody seems excited by them. It’s interesting that these two sentences were written next to each other. I get the (outsider’s) impression that they were written using something like ASIO as the standard use case, which is indeed one of long-lived coroutines. I’m not sure anyone else participated who had a different application. The second observation “nobody seems excited by them” is generally waved away by saying “get it into the standard so library writers can add sugar” (which implies that such sugar will make it into the c++26 or 29, if at all). I’m generally pretty happy with the direction the committee has been moving in since C++17 or even 14. But I agree coroutines don’t seem to have quite made it.
- vlovich123 5y agoA coworker added coroutines to KJ [1] so for our purposes it’s “made it”. It’ll be more broadly useful obviously with library support in the standard. I think that’s targeted for c++23 [1] https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#coroutines https://github.com/capnproto/capnproto/blob/master/kjdoc/tou...
- voldacar 5y agoI see this C++ coroutines thing as a desperate cry for real AST macros, but the godawful syntax of c++ just can't really make that work. And besides, people would complain even more if everyone made their own version of coroutines. Maybe it would be possible to make a s-expression language with sane syntax that transpiled to C++ code and let you do arbitrary compile-time AST macros. You wouldn't have to rely on Turing-complete template insanity or whatever half-baked feature the committee shat out last. In principle it wouldn't even be that difficult to make something like this, since it wouldn't have to be an actual lisp. Might be an interesting project
- skyleradams 5y agotest
- outside1234 5y agoNothing in C++ sparks joy so that fits right in.
- whalesalad 5y agoDoes any element of C++ spark joy?
- nitwit005 5y agoThe call to new can't really be avoided with this style of coroutine. You have to put the state somewhere. I'll agree there's some ugliness, but it's way nicer than trying to do something without compiler support. I looked into coroutine libraries previously, and I just gave up on them as being too much of a hack.
- phekunde 5y agoAs they say, if you are starting a project to solve a problem, and choose C++ as a language, then you now have three problems: the original problem, the C++ language complexity, and the third is the maintenance hell afterwards. C++ language development is a classic case of what feature creep looks like for a software project that is on the path to self-harm.
- 72deluxe 5y agoSurely you can replace "C++" with any other language and it'd still be true? I look at the colossal ancient Delphi codebase that my old employer had as a great example. Or the Magento system in PHP as another example. Or all the Objective C in the world that won't work on modern macos or iOS/iPadOS as another example.
- account4mypc 5y agoI agree, but I think in 5 years we will be using coroutines regularly. Just need to let the standard library catch up.
- Matthias247 5y agoI was a fan of async code 10 years ago, but now I'm getting more and more a believer that all those coroutine/fiber/etc models "do not spark joy". It's not just the C++ version. One thing which usually happens is that engineers get overwhelmed with 2 threading models: They might already have a hard time to understand how normal threading works, and coroutines add another dimension on top of that. That's a non-issue for the engineers working on the proposals and some of the affected libraries since they are domain experts, but the minority of implementors of an API server or users of a HTTP client are actually IO experts. The second thing which usually happens is that a couple of ecosystems start to exist on top of the foundations which are incompatible with another. So you no longer write code in C++, Rust, Python, Java etc. You are writing code in asio, tokio, asyncio or netty. While most of these e.g. have some interoperability or can coexist with other async runtimes running on different threads it's also not something easy. And last but not least every one of the implementations has another set of limitations that one or the other person will be unhappy about. Whether its additional heap allocations, mandatory synchronization, lazy vs immediate execution, cancellation behaviors, etc. All in all coroutines seem good tools to make reaching performance goals in a way that's a bit more pleasant compared to what we had 10 years ago (callbacks), but they always seem to be a compromise. I'm wondering whether at some point we will see an uptake on fixing the shortcomings of plain threads to avoid having to reach out for coroutines and a decline in those. But security challenges and mitigations make it continuously harder to decrease system call overhead.
- nicoburns 5y ago> One thing which usually happens is that engineers get overwhelmed with 2 threading models: They might already have a hard time to understand how normal threading works, and coroutines add another dimension on top of that. That's a non-issue for the engineers working on the proposals and some of the affected libraries since they are domain experts, but the minority of implementors of an API server or users of a HTTP client are actually IO experts. IMO it's traditional threading that's hard to get your head around not async. Pre-emption makes things much more complex.
- pas 5y ago
- deleted 5y ago[deleted]
- musicale 5y agoThat's probably OK since C++ does not spark joy either - the language is mostly a superset of some things that have been lying around for a while which you may or may not want, combined into a somewhat usable system. At times I almost think there might be subset of C++ that sparks more joy - sometimes I try to program in it!
- physicsguy 5y agoMy understanding was that the aim of the implementation here isn't really to be used by users, but to allow library maintainers to use them as the basis for user consumable coroutines.