Coroutines as a technique to implement state machines is the first things which comes to my mind. It's a more abstract and requires a way less fundamentals to know comparing to concurrency.
But coroutines really only work any better than "objects" if you understand the implication to the stack pointer? Which requires understanding exactly what a thread is. Right?
That is, a basic class that has defined state and methods to modify the state is already enough to explain a state machine. What makes coroutines better for it?
The issue with state you should handle it. Compare for example some iterator implementation in Java and Python. Latter needs only one method with coroutine and no state to store on object level.
> the state is already enough to explain a state machine.
I did not talk about explaining state machines but implementing state machines as coroutines. Progression: give an idea of state machines, show how hard is to handle state, present coroutines as way to handle states.
taeric|4 months ago
That is, a basic class that has defined state and methods to modify the state is already enough to explain a state machine. What makes coroutines better for it?
bvrmn|4 months ago
> the state is already enough to explain a state machine.
I did not talk about explaining state machines but implementing state machines as coroutines. Progression: give an idea of state machines, show how hard is to handle state, present coroutines as way to handle states.