- 1 minute read

Bruce Eckel has published some interesting thoughts about closures and lambda expressions in Java 8. He claims that Java's lambdas are essentially closures because the original definition of closures stems from functional programming languages, and pure functional languages don't know variables. Hence, Java's restriction that lambdas can only access effectively final variables of the surrounding scope is not a real restriction, he claims. Plus, it can be circumvented by encapsulating the interesting variable in an object. Basically, that's the same trick Java programmers use to implement call-by-reference parameters.

I can't say I really agree with Bruce Eckel. In my eyes closures are a lot more useful than lambda expressions because they can access variables of the surrounding scope, while lambda can only access constant values of the outer scope. But it's an interesting article nonetheless. Read the full story on Bruce Eckel's blog.


Comments