4 ms·
I don't agree. You can handle errors how you like on both approaches. The callback code, however, will get pretty messy once you have a branched control flow.
by jcarrano 3y ago
I don't agree. You can handle errors how you like on both approaches. The callback code, however, will get pretty messy once you have a branched control flow.
With coroutines you are using the language's control structures directly. The program counter is your state and a branch is an `if`. With minimal debugger support you will be able to see at which line is the execution on each coro.
With callbacks you would have to inspect which ones are pending, unless you have made the state explicit in a variable.
These is not a huge deal for those who have been programming for a while but for beginners coros will feel more like an extension of the language than something built on top.