The type `Future<T>` and the language construct `async-await` goes hand to hand. Within the JavaScript ecosystem, this is more commonly known as the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
# [async-await](https://en.wikipedia.org/wiki/Async/await)
[[FSharp|F#]] introduced it first in 2007; C# officially added it in 2012. This is the language feature that made [[JavaScript]] into an ergonomic language, as before this the callback hell was quite difficult to program against.
The polyfill for async-await is quite sophisticated. It needs to implement coroutines via translating the code to a non-coroutine code. This is done via maintaining different code paths as a state, and making sure one can resume operation after a yield statement.
Once JavaScript supported coroutines, the polyfills became simpler, as the coroutine generators can be used directly. Nowadays, no polyfill is
needed.
# Eager vs Lazy
- In [[JavaScript]], promises are eager;
- In [[Python]], Futures are lazy, Tasks are eager.
# Articles
- https://without.boats/blog/let-futures-be-futures/