Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.

Java 8 Revealed: Lambdas, Default Methods and Bulk Data Operations

Now, I’ve been writing about this in bits and pieces for a few months now, and wanted to pull it all together into a single publication (you can download our pretty PDF version as well). I’m talking about Java 8, the long-awaited release. And even though some delays have occurred along the way, many believe it’s going to be worth it because of three major additions to the language: Lambdas, default (or defender) methods, and bulk data operations.

In case you’re hearing about it for the first time, Project Lambda is the major theme in the upcoming Java 8 and probably the most awaited feature for Java developers. Lambdas, as a language feature, do not come alone: to get most out of lambdas, you’re gonna need interface improvements for the standard JDK libraries.

The main driver behind the new lambda feature et al is the hardware trend of going towards multi-core. Chip designers have nowhere to go but parallel, and software developers must find out a better way to utilize the features of the underlying hardware. For application developers, and in our case Java developers, need simple parallel libraries to make their work more efficient. The obvious place to start for such an evolution is the parallelization of collections. Lambdas, it turns out, are great for improving the readability of your code and the expressiveness of the language.

It would be fair to say that without more language support for parallel idioms, people will instinctively reach for serial idioms. Hence, the new parallel idioms should be simple, intuitive and easy to use.

The code that we write today is inherently serial. Consider the following example:

List persons = asList(new Person("Joe"), new Person("Jim"), new Person("John"));
for(Person person : persons) {
  doSomething(person);
}

Historically, Java collections were not capable of expressing internal iterations, as the only way to describe an iteration flow was the for (or while) loop. The example above describes an iteration over the collection of elements and there’s no good way to express that the elements of the collection could be processed concurrently. However, with the new additions to the Java language, we could describe the same operation in a slightly different way:

List persons = asList(new Person("Joe"), new Person("Jim"), new Person("John"));
persons.forEach(this::doSomething);

Now, if the underlying library implementation actually supports parallel operations, the elements of the collection could be processed concurrently. We can just pass the operation into the forEach method and rely on it to perform computation for us. All the new language features that are being added to Java 8 are actually the tools to enable the path to multi-core and parallel libraries.

In this investigation, we provide the overview of the new language features in Java 8, such as lambda expressions and default methods. And as the goal of these language changes is to improve collections library, we will also cover some of new stuff in that area.

Here’s what you will learn about by reading this RebelLabs report:

  • Lambdas in Java 8: lambda syntax, SAM types, functional interfaces
  • Default methods: the what, why, and how
  • Bulk data operations for Java collections: the new way to express operations for data processing


Download the PDF