The dark side of lambda expressions in Java 8

And now for something completely different, as Takipi CEO Tal Weiss points out that not all is completely well in Java Lambda Land: 

The JVM was built to be language agnostic in the sense that it can execute code written in any language, as long as it can be translated into bytecode. The bytecode specification itself is fully OO, and was designed to closely match the Java language. That means that bytecode compiled from Java source will pretty much resemble it structurally.

As Weiss notes, the farther away we get from Java's object-oriented roots, the greater the difference between your source code and the executed bytecode will be, as "[l]arge amounts of synthetic classes, methods and variables are added by the compiler to get the JVM to execute the semantics and flow controls required by the language."

The problem, according to Weiss, is that the Java compiler has been extended to support lambda functions but the JVM has not. In essence: "Java developers will pay for concise code with more complex debugging, and longer synthetic call stacks." 

More discussion with code samples on Takipi Blog ...

This story, "The dark side of lambda expressions in Java 8" was originally published by Java Everywhere.

Join the discussion
Be the first to comment on this article. Our Commenting Policies