Why it matters
Futures replace callback pyramids with linear-looking code. Understanding them is essential for modern async programming.
Advertisement
The architecture
Future: read-only value. Completion states: pending, completed with value, completed with error.
Promise: writable side. set_value or set_error completes the future.
Advertisement
How it works end to end
Composition: chain futures with then/map/flatMap. Errors propagate through chains.
async/await: syntactic sugar over futures. Makes code linear.
All/Any combinators: wait for multiple futures.