Small, Fast, & Simple

April 20, 2015

Laziness

Small
Fast
Simple

One of Haskell’s key features is lazy evaluation. Expressions are not evaluated until they are needed. This is also a valuable technique for writing programs. For example, rather than writing all the lowest-level database code first, start with user-facing code and work down through the layers of the application, writing only the code that has to be written to support the top-level changes.

There are also other ways to consider laziness in programming. Larry Wall considers it one of the three virtues of great programmers. Laziness is also a weapon against the temptation to prematurely optimize.