Chapter 1. Introduction
Before we begin our exploration of what lambda expressions are and how we can use them, you should at least understand why they exist to begin with. In this chapter, I’ll cover that and also explain the structure and motivation of this book.
Why Did They Need to Change Java Again?
Java 1.0 was released in January 1996, and the world of programming has changed quite a bit since then. Businesses are requiring ever more complex applications, and most programs are executed on machines with powerful multicore CPUs. The rise of Java Virtual Machines (JVM), with efficient runtime compilers has meant that programmers can focus more on writing clean, maintainable code, rather than on code that’s efficiently using every CPU clock cycle and every byte of memory.
The elephant in the room is the rise of multicore CPUs. Programming
algorithms involving locks is error-prone and time-consuming. The
java.util.concurrent package and the wealth of external libraries have
developed a variety of concurrency abstractions that begin to help programmers
write code that performs well on multicore CPUs. Unfortunately, we haven’t gone
far enough—until now.
There are limits to the level of abstractions that library writers can use in Java today. A good example of this is the lack of efficient parallel operations over large collections of data. Java 8 allows you to write complex collection-processing algorithms, and simply by changing a single method call you can efficiently execute this ...