Wednesday, March 26, 2014

Java 8

Andrew Binstock:

What makes Java 8 so compelling is its embrace of the functional programming metaphor. This embrace has two primary expressions: the use of closures (or as Java calls them, “lambdas”) and the adoption of composition as a central approach to development. Lambdas, while not quite full first-class functions, enable passing code as a parameter to a function, within limited contexts. By limited, I mean only the mechanics of it, not the opportunities to do so. As Brian Goetz of Oracle explains in one of this week’s features, once the syntax of lambdas had been finalized and its implementation completed, the Java team found numerous opportunities to use lambdas to streamline the standard libraries. They discovered that not only was the code clearer, but the performance better.

[…]

The new streams feature in Java 8 enables composability. This language trait, recently explained by Walter Bright, enables software to be implemented using a model that operates like this: data source → algorithm → data sink. This model is highly desirable on today’s platforms where such computational streams can be run in parallel and thereby make full use of multicore processors. It is also an excellent fit in processing Big Data.

Java has long supported lambdas in the form of anonymous inner classes, but the new lambda syntax is much more compact.

Comments RSS · Twitter

Leave a Comment