4 ms·
Implementing async/await is only a compiler change, so it can be implemented rather easily on top of any languages, the compiler transforms the code to a state
by _old_dude_ 6y ago
Implementing async/await is only a compiler change, so it can be implemented rather easily on top of any languages, the compiler transforms the code to a state machine.
co-routine (Java Loom's one, Go one, Scheme one, etc) requires to be able to serialize and deserialize a part of the stack (move the stack on the the heap and vice versa), so it's hard/impossible to implement with non managed runtimes which like in C or objective C.
In C, you can declare an address/pointer to an address on stack (using &), but with a co-routine mechanism, the addresses of parts of the stack are not constant.
If you have a managed runtime, you rewrite those kind of pointers when you copy parts of the stack back and forth.
- gpderetta 6y agoWith one stack per coroutine you do not have to move stack frames. It has different tradeoffs of course.