| ▲ | travisgriggs 19 hours ago | |||||||
> Instead of callbacks, you write code that looks sequential [but isn’t] (bracketed statement added by me to make the implied explicit) This sums up my (personal, I guess) beef with coroutines in general. I have dabbled with them since different experiments were tried in C many moons ago. I find that programming can be hard. Computers are very pedantic about how they get things done. And it pays for me to be explicit and intentional about how computation happens. The illusory nature of async/await coroutines that makes it seem as if code continues procedurally demos well for simple cases, but often grows difficult to reason about (for me). | ||||||||
| ▲ | jesuslop 18 hours ago | parent | next [-] | |||||||
That is the price you pay. If you refuse to pay you are left to express a potentially complex state machine in terms of a flat state-transition table, so you have a huge python cases statement saying on event x do this and on event y do that. That obscures evident state-chart sequentiality, alternatives or loops (the stuff visible in the good old flow-charts) that otherwise could be mapped in their natural language constructs. But yes, is not honest flow. Is a tradeoff. | ||||||||
| ▲ | jshier 8 hours ago | parent | prev [-] | |||||||
> looks sequential [but isn’t] This is just wrong. It looks sequential and it is! What the original author means is that it looks synchronous but isn't. But of course that's not really true either, given the use of the await keyword, but that can be explained by the brief learning curve. Swift concurrency may use coroutines as an implementation detail, but it doesn't expose most of the complexity of that model, or exposes it in different ways. | ||||||||
| ||||||||