The 'primitive' SCUMM language used for writing Adventure Games like Maniac Mansion had coroutines - an ill fated attempt to convert to using Python was hampered by Python (at the time) having no support for yield.
I did not know that, that's neat. Are there any blog posts or articles that go deeper into this?
Looking at Unity made me understand the point of C++ coroutines
161–170 of 190 posts
Re: Looking at Unity made me understand the point of C++ coroutines
#162> turns it into some sort of ugly state machine Why are people afraid of state machines? There's been sooo much effort spent on hiding them from the programmer...
Re: Looking at Unity made me understand the point of C++ coroutines
#163I do not find so called "green threads" useful at all. In my opinion except some very esoteric cases they serve no purpose in "native" languages that have full access to all OS threading and IO facilities. Useful only in "deficient" environments like inherently single threaded request handlers like NodeJS.
Yeah I agree that user threads are overused by programmers. For most situations, using an OS thread is going to be far easier to work with. People like to cite the drawback that context switching overhead becomes a problem when you have thousands of threads, but the reality is that most people are not writing software that needs to handle many thousands of users all at once. Using green threads to handle such large s…
Re: Looking at Unity made me understand the point of C++ coroutines
#164Re: Looking at Unity made me understand the point of C++ coroutines
#165Earlier quoted context omitted.
> as to be daunting/inconvenient to use I don't even know how to respond to that. How in the world are you using C++ professionally if you think coroutines are "daunting"? No one uses C++ for it's "convenience" factor. We use it for the power and control it affords. > What I was thinking of as a state machine with using std::future was a single function state machine, using switch (state) to the state specific dispat…
So it's meant to be inconvenient, and that's the only right and proper way?! Sounds more like punishment than software design, but each to their own.
It’s pretty clear you’ve never built a production-grade async state machine.
C++ is designed to provide the plumbing, not the kitchen sink. It’s a language for building abstractions, not handing them to you — though in practice, there’s a rich ecosystem if you’d rather reuse than reinvent.
That flexibility comes at the cost of convenience, which is why most new engineers don’t start with C++.
What you call “intimidating,” I call powerful. If coroutines throw you off, you’re probably using the wrong language.
Last thought — when you run into someone who’s built the tools you rely on, ask them questions instead of trying to lecture them. I would have been more than happy to work through a pedagogical solution with you.
/ignored
Re: Looking at Unity made me understand the point of C++ coroutines
#166Earlier quoted context omitted.
Using structured concurrency [1] as introduced in Python Trio [2] genuinely does help write much simpler concurrent code. Also, as noted in that Simon Tatham article, Python makes choices at the language level that you have to fuss over yourself in C++. Given how different Trio is from asyncio (the async library in Python's standard library), it seems to me that making some of those basic choices wasn't actually that…
After so wrote the comment below I realized that it really is just ‘um, actually…’ about discussing using concurrency vs implementing it. It’s probably not needed, but I do like my wording so I’m posting it for personal posterity. In the context of an article about C++’s coroutines for building concurrency I think structured concurrency is out of scope. Structured concurrency is an effective and, reasonably, efficien…
Re: Looking at Unity made me understand the point of C++ coroutines
#167Earlier quoted context omitted.
Using structured concurrency [1] as introduced in Python Trio [2] genuinely does help write much simpler concurrent code. Also, as noted in that Simon Tatham article, Python makes choices at the language level that you have to fuss over yourself in C++. Given how different Trio is from asyncio (the async library in Python's standard library), it seems to me that making some of those basic choices wasn't actually that…
Python's stdlib now supports structured concurrency via task groups[1], inspired by Trio's nurseries[2]. [1] https://docs.python.org/3/library/asyncio-task.html#id6 [2] https://github.com/python/cpython/issues/90908
I will say that it's still not as nice as using Trio. Partly that's because it has edge-triggered cancellation (calling task.cancel() injects a single cancellation exception) rather than Trio's level-triggered cancellation (once a scope is cancelled, including the scope implicit in a nursery, it stays cancelled so future async calls all throw Cancelled unless shielded). The interaction between asyncio TaskGroup and its older task API is also really awkward (how do I update the task's cancelled count if an unrelated task I'm waiting on throws Cancelled?). But it's a huge improvement if you're forced to use asyncio.
Re: Looking at Unity made me understand the point of C++ coroutines
#168Earlier quoted context omitted.
So it's meant to be inconvenient, and that's the only right and proper way?! Sounds more like punishment than software design, but each to their own.
I get what you’re saying, but you kicked off this thread like an expert — even though you knew you were talking to someone who helped build the very thing you’re critiquing. It’s pretty clear you’ve never built a production-grade async state machine. C++ is designed to provide the plumbing, not the kitchen sink. It’s a language for building abstractions, not handing them to you — though in practice, there’s a rich ec…
Haha .. you have no idea.
FWIW I've built frameworks exactly for that, and it's highly likely that you've unwittingly used one of them.
Re: Looking at Unity made me understand the point of C++ coroutines
#169Earlier quoted context omitted.
I get what you’re saying, but you kicked off this thread like an expert — even though you knew you were talking to someone who helped build the very thing you’re critiquing. It’s pretty clear you’ve never built a production-grade async state machine. C++ is designed to provide the plumbing, not the kitchen sink. It’s a language for building abstractions, not handing them to you — though in practice, there’s a rich ec…
> It’s pretty clear you’ve never built a production-grade async state machine. Haha .. you have no idea. FWIW I've built frameworks exactly for that, and it's highly likely that you've unwittingly used one of them.
Re: Looking at Unity made me understand the point of C++ coroutines
#170No serious devs even uses Unity coroutines. Terrible control flow and perf. Fine for small projects on PC.