Łukasz Wróbel

From the archive

Java 8: Lambdas and Collection Handling

Written in 2015. Tools move on, but the basics here still hold.

Since I like to stay up-to-date with at least the most important programming languages, libraries and frameworks, I finally decided to take a good look at lambdas introduced in Java 8.

Having been struck by both power and elegance of the Ruby’s Enumerable module, since then I’ve been beginning new programming language evaluation process by checking how it facilitates collection handling. Keeping in mind how verbose it was in Java, I opted for Scala and Clojure when it came to JVM-based languages.

After examining Java 8 lambdas, I came to a conclusion that they tip the scales in favor of Java; the reasons for picking one of the alternative JVM languages are not that obvious to me anymore. Not to mention the hacks required to maintain binary compatibility, Java 8 Stream API is more well-thought-out than I expected.

How to make the code more concise and readable? How do the closures work? How are the lambda types being described in method signatures? What had to be sacrificed in order to maintain binary compatibility? How the collection operations can be parallelized? Is it always beneficial?

If you want to get to know the answers, take a look at the slides: Java 8 Lambdas and Collection Handling

This article was originally published under CC BY-SA 4.0.