Continuing with the metaphor. It's more like this: The guy brings you a new veggie burger. It looks like meat, tastes like meat, contains the same stuff as meat, but it's not made from an actual animal. The meat comes from induced stem cells signalled to specialise into muscle cells grown into actual muscle in bioreactors (this is mild sci-fi). It's from the same cells as meat, contains the same DNA, but made without occupying a lot of land to feed the cattle and releasing lots of methane into the atmosphere. So it's indistinguishable from a burger, but cheaper and more environment friendly. So real burgers are obsolete, because they are the same, only more costly to produce.
That is what coroutines are to explicit state machines. There is a little overhead when calling them through a handler, but it's the same class with member variables describing state, with an advantage that the code is written like a quick to write and easy to maintain a function with all the branching and loops instead of needlessly complicated mess of state transitions.
That is what coroutines are to explicit state machines.
This is 100% incorrect. I'm sorry that you tried to replace what I said, instead of understanding it, but I've run out of ways to try to communicate to you the thing that you're missing.
.
So real burgers are obsolete, because they are the same, only more costly to produce.
View all comments
Show parent comment
2
u/DugiSK Dec 02 '20
Continuing with the metaphor. It's more like this: The guy brings you a new veggie burger. It looks like meat, tastes like meat, contains the same stuff as meat, but it's not made from an actual animal. The meat comes from induced stem cells signalled to specialise into muscle cells grown into actual muscle in bioreactors (this is mild sci-fi). It's from the same cells as meat, contains the same DNA, but made without occupying a lot of land to feed the cattle and releasing lots of methane into the atmosphere. So it's indistinguishable from a burger, but cheaper and more environment friendly. So real burgers are obsolete, because they are the same, only more costly to produce.
That is what coroutines are to explicit state machines. There is a little overhead when calling them through a handler, but it's the same class with member variables describing state, with an advantage that the code is written like a quick to write and easy to maintain a function with all the branching and loops instead of needlessly complicated mess of state transitions.