Skip to Content
Functional Programming in Java
book

Functional Programming in Java

by Venkat Subramaniam
February 2014
Intermediate to advanced
160 pages
4h 59m
English
Pragmatic Bookshelf
Content preview from Functional Programming in Java

Chapter 6Being Lazy

Progress is made by lazy men looking for easier ways to do things.

Robert A. Heinlein

In Java we often execute code eagerly. The arguments are evaluated right at the time of method calls, for example. There’s a good reason for that; eager code is easy to write and to reason about. But delaying commitments until the last responsible moment is a good agile practice. When executing code, we can gain in performance by being just a little lazy. Eager is simple, but lazy is efficient. Now we can easily be lazy and make things simple and efficient.

If we use heavyweight objects in a program, we want to postpone creating them. Certainly we’d delay running any expensive computations until we really need them. Paradoxically, laziness ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in Java

Functional Programming in Java

Pierre-Yves Saumont

Publisher Resources

ISBN: 9781941222690Errata Page