I’ve just read a french article about Java 8’s lambdas about the usefulness - or lack thereof - of them in day-to-day programming with some frameworks. As we do lot of Swing and GWT programming at work it seemed interesting to know if lambdas could speed up the development and improve the readability, thus the maintanability.

It turns out that the introduction of lambda’s won’t affect that much the code. Why ?

Well, decision has been taken that lambda’s would be like a syntactic sugar for Single Abstract Method (SAM) interfaces, that is interfaces defining only one method. Luckily there are many of them in the JDK, for example. We can cite Callable, Runnable, Comparator, ActionListener, …. So it’s nice. But, unfortunately, there are also many interfaces with multiple methods, especially in GUI frameworks/libraries. Those interfaces won’t benefit of lambda syntax.

So, to summarize, only 17 interfaces on 41 in the packages javax.swing.event and java.awt.event may be elected as SAM interfaces and therefore may be used with lambdas. Less than 50%, not a big win.

For me it’s clear : the JCP tries to appeal programmers with “new features” coming from other languages, but it fail to implement them fully. I guess the technical reason behind that is “backward compatibility”, but I’m not sure.

Anyway, I’m a bit disappointed with the state of lambda in Java and it only comforts me in going deeper in other languages such as Scala or Clojure.