3 ms·
In fact python had general coroutines first in yield, which is mostly used for iteration (“generators”) and state machines. Some frameworks (e.g. twisted) did
by masklinn 3y ago
In fact python had general coroutines first in yield, which is mostly used for iteration (“generators”) and state machines.
Some frameworks (e.g. twisted) did use them for concurrency, and the core team originally planned something similar, however the ergonomics were not what they wanted (especially when mixing coroutines-for-concurrency and coroutines-for-iteration), so they went for a more specialised design.
- ackfoobar 3y ago> did use them for concurrency > went for a more specialised design My impression is that JS evolved similarly - (ab)using generator for concurrency, then specialized async-await as a language feature.
- masklinn 3y agoKinda? But that was a very short cycle, both promises and generators were added to the language in ES6 (though the community had been coalescing around promises — “thenables” — for a while), the first draft for async functions was actually created during the development cycle of ES6, and it was shipped in ES7.