liveBook · Manning

Lazy evaluation

Lazy evaluation is an evaluation strategy that defers computing an expression or value until its result is needed, potentially avoiding the computation entirely.

How 13 Manning books explain it

Functional Programming in Scala, Second Edition

Lazy evaluation defers evaluating an expression until its value is required.

How it is used
Uses lazy lists to fuse transformations, avoid unnecessary work, and separate computation descriptions from their evaluation.
How deep it goes
Defines thunks, forcing, memoization, and by-name parameters, then develops lazy-list operations and parser-combinator nonstrictness.
Examples
Traces chained List and LazyList transformations; implements exists, take, map, filter, infinite streams, unfold, and parser many.
What you can do after
Build it from scratch with thunk-backed LazyList constructors and apply nonstrict folds to stop traversal early.

Read how Functional Programming in Scala, Second Edition explains lazy evaluation →

Fast Python: High performance techniques for large datasets

How it is used
Uses deferred work to process large data pipelines with less simultaneous allocation and sometimes avoid unneeded computation.
How deep it goes
Works through a Python generator and Dask task-graph execution, including cases where eagerness or expensive operations remain.
Examples
Uses CSV temperature parsing, a range-versus-list timing comparison, and a Dask property-tax data-frame pipeline.
What you can do after
Apply it via Python generators or Dask, checking when work runs and whether eager results better suit repeated visits.

Read how Fast Python: High performance techniques for large datasets explains lazy evaluation →

Tiny Python Projects: Learn coding and testing with puzzles and games

A lazy function defers producing a result until that result is needed.

How it is used
Uses deferred iteration for ranges, reverse sequences, mapped values, and filtered elements consumed by loops or other operations.
How deep it goes
Defines deferral and demonstrates materialization with list(), but stops short of implementation internals.
Examples
Demonstrates character indexes, reverse counting, consonant filtering, car selection, and vowel replacement.
What you can do after
Apply it via Python's list(), loops, join(), map(), and filter() to control when iterable results are produced.

Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains lazy evaluation →

Functional Programming in JavaScript

An evaluation strategy that delays computing an expression until its value is required.

How it is used
Optimizes functional JavaScript by deferring unnecessary computations, especially when processing large inputs or selecting subsets.
How deep it goes
Explains eager-versus-lazy execution, conditional deferral, alternation, and Lodash shortcut fusion, but does not develop language-level lazy evaluation internals.
Examples
Uses range with take, Maybe with a fallback, student lookup, Lodash chains, and an enrollment-average pipeline.
What you can do after
Apply it via Lodash chains and functional combinators to defer unused work and limit processing to requested results.

Read how Functional Programming in JavaScript explains lazy evaluation →

Kotlin in Action, 2E

Lazy evaluation postpones computation until a result is required and can stop processing once that result is obtained.

How it is used
Uses Kotlin sequences to execute collection-operation chains efficiently without storing intermediate collections.
How deep it goes
Explains intermediate and terminal operations, evaluation order, short-circuiting, and filter placement, stopping short of implementation internals.
Examples
Demonstrates asSequence pipelines, observable map and filter execution, toList triggering, and find stopping after a matching result.
What you can do after
Apply it via Kotlin sequences to reduce intermediate collections and avoid unnecessary element processing.

Read how Kotlin in Action, 2E explains lazy evaluation →

Learn Haskell by Example

Lazy evaluation delays evaluating an expression until its value is required.

How it is used
Uses deferred computation to avoid unnecessary work during graph search and other data-processing operations.
How deep it goes
Explains forcing, discarded arguments, lazy data structures, performance trade-offs, and strict alternatives without detailing runtime implementation.
Examples
Demonstrates `const` with an enormous integer, incremental ladder-game graph construction, and lazy versus strict folds.
What you can do after
Evaluate when laziness avoids work, select lazy structures for searches, and diagnose memory risks using strict folds or StrictData.

Read how Learn Haskell by Example explains lazy evaluation →

The Well-Grounded Rubyist, Fourth Edition

Lazy evaluation defers producing results until they are requested rather than materializing all results in advance.

How it is used
Uses lazy enumerators to process large or infinite sequences while requesting only the results a downstream operation needs.
How deep it goes
Explains enumerator mechanics, lazy chaining, infinite ranges, finite prefixes, and recursive aggregation through executable examples.
Examples
Demonstrates paired animal slices, infinite multiples, square sequences, and recursive powers-factorial summation.
What you can do after
Apply it via Ruby lazy enumerators to filter, map, and consume finite prefixes of large or infinite sequences.

Read how The Well-Grounded Rubyist, Fourth Edition explains lazy evaluation →

Snowflake Data Engineering

Lazy execution is an evaluation strategy that postpones running data operations until a triggering operation requires their results.

How it is used
Uses deferred Snowpark data-frame execution to batch pipeline operations before inspection or persistence.
How deep it goes
Explains execution triggers, batching, and client-transfer effects, but does not detail internal query planning.
Examples
Demonstrates holiday_flags, collect(), DIM_DATE, and save_as_table("DIM_DATE") in a Snowpark pipeline.
What you can do after
Apply it via Snowpark by batching data-frame operations and triggering execution with collect(), count(), show(), or save_as_table().

Read how Snowflake Data Engineering explains lazy evaluation →

Python How-To

Lazy evaluation is an evaluation strategy in which an operation or value is computed only when its result is needed.

How it is used
Uses deferred computation to reduce unnecessary processing and memory use in generators and class attributes.
How deep it goes
Explains on-demand generator state and cached property loading, stopping short of broader language-specific implementation details.
Examples
Demonstrates perfect-square generators and User follower profiles loaded from a remote server.
What you can do after
Apply it via Python generators and properties to defer expensive work and retain results after first access.

Read how Python How-To explains lazy evaluation →

Object-Oriented Software Design in C++

The Lazy Evaluation Principle is a design principle that delays an expensive calculation until its result is needed.

How it is used
Improves runtime performance by deferring expensive date conversions until getters or arithmetic require their results.
How deep it goes
Defines the principle and demonstrates synchronized representations, validity flags, and demand-triggered conversion; it stops short of general algorithms.
Examples
Uses a Date class that converts between calendar fields and Julian day numbers only when access or arithmetic requires synchronization.
What you can do after
Apply lazy evaluation by tracking representation validity and validating each representation immediately before its use.

Read how Object-Oriented Software Design in C++ explains lazy evaluation →

Idiomatic Rust

Lazy evaluation is an execution strategy that postpones computing an expression until its result is required.

How it is used
Uses lazy evaluation to defer iterator transformations until a collection or other operation requires their results.
How deep it goes
Explains that map returns another iterator and collect forces evaluation, without detailing iterator internals.
Examples
Demonstrates converting array integers to strings with map and collect.
What you can do after
Apply lazy transformations with Rust iterator methods such as map, then force results with collect.

Read how Idiomatic Rust explains lazy evaluation →

Software Design for Python Programmers

The Lazy Evaluation Principle postpones a calculation until its result is required, particularly when the calculation is expensive or time-consuming.

How it is used
Improves runtime performance by postponing expensive date-representation conversions until getters or arithmetic operations require them.
How deep it goes
Explains deferred conversion, synchronized representations, validity flags, and encapsulated access, without detailing conversion algorithms.
Examples
Uses a Date class whose getters validate year-month-day values while arithmetic methods validate Julian day numbers.
What you can do after
Apply it by guarding expensive conversions with validity checks and triggering them at the first operation that needs their results.

Read how Software Design for Python Programmers explains lazy evaluation →

Fabulous Adventures in Data Structures and Algorithms

Laziness is an evaluation strategy that defers computation until its result is needed.

How it is used
Uses deferred computation to represent large sequences and compose workflows without immediately producing every result.
How deep it goes
Explains iterator-based deferral, eager-versus-lazy trade-offs, and Map and Bind, but does not develop evaluation internals.
Examples
Demonstrates lazy Cartesian products and Lazy<T> transformations with Map and Bind.
What you can do after
Build it from scratch with C# iterators and compose lazy workflows using Map and Bind.

Read how Fabulous Adventures in Data Structures and Algorithms explains lazy evaluation →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.