A fluent programming is the programming technique where operations return a value that allows the invocation of another operation. With the fluent programming, it is perfectly natural to end up with one huge statement that is the concatenation of as many operations as you like. The Java Development Kit (JDK) streams (added in Java 8) are designed to support fluent programming. Instead of looping over all elements in the sequence repeatedly (once for filter, then again for map, and eventually for toArray), the chain of filtermapper-collector can be applied to each element in just one pass over the sequence. In this context, we often encounter lambda expressions used to create locally defined anonymous functions. They provide a clear and concise way to represent one method interface using an expression. Oracle claims that use of lambda expressions also improve the collection libraries making it easier to iterate through, filter, and extract data from a collection. In addition, new concurrency features improve performance in multicore environments.
There are multiple ways to traverse, iterate, or loop collection in Java. Therefore, to solve one problem, we have several options for solutions that differ by undeniably increasing of the code readability. Searching for answers to the question of whether these new features really bring performance benefits over conventional way, is the subject of this paper.
If the inline PDF is not rendering correctly, you can download the PDF file here.
LANGER A. and KREFT K. 2013. Lambda Expressions in Java. [online]. [cit. 2017-03-10]. Available on internet: ⟨http://www.angelikalanger.com/Lambdas/Lambdas.pdf⟩.
LANGER A. 2015. Java performance tutorial — How fast are the Java 8 streams? [online]. [cit. 2017-03-10]. Available on internet: ⟨https://jaxenter.com/java-performance-tutorial-how-fast-are-the-java-8-streams-118830.html⟩.