Futures provide the building blocks for asynchronous computations with zero-cost abstraction. Asynchronous communication is useful for handling timeouts, computing across thread pools, network responses, and any function that does not immediately return a value.
In a synchronous block, the computer would execute each command sequentially after waiting for each command to return a value. If you were to apply the synchronous model when sending an email, you would send the message, stare at your inbox, and wait until you have received a response from your recipient.
Fortunately, life does not work synchronously. After we send an email, we could switch to another application or get off our chair. We can start performing other tasks such as getting the groceries, cooking dinner, or reading a book. Our attention can focus on, and perform, other tasks simultaneously. Periodically, we will check our inbox for a response from our recipient. The process of periodically checking for...