Chapter 12
Lazy Evaluations and Parallel Collections

Responsiveness—that’s one thing that can make or break just about any application. Other factors like business value, ease of use, availability, cost, and resilience, are also important. But responsiveness is at the top—we humans take about 250 milliseconds to cognitively perceive any action; after five seconds any delay begins to feel like eternity. Any effort to lower the response time will directly impact our ability to make customers happy and, in turn, earn their loyalty.

You can make applications responsive in one of two ways. You could run computations faster by using multiple threads—that is, instead of running tasks one after another, run them in parallel. Alternatively, instead of running faster, run wisely. Postpone execution of tasks until the last possible moment.

Postponing, or evaluating lazily, can help in two ways. First, you can run tasks that are relevant now and get to those other tasks later. Second, if the results of the postponed tasks are not needed for the job on hand, you saved the time and resources that would otherwise go into running those tasks. This is often called lazy evaluation, and it’s a great way to gain efficiency and responsiveness.

In this chapter you’ll learn how to make use of both of these techniques—to apply lazy evaluations and to exploit parallelism using collections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.112.210