[quote=“princec,post:34,topic:40839”]
[quote=“Varkas,post:35,topic:40839”]
So if the goal is to be able to write code that clearly shows developer intent and you knew for a fact that the following pieces of code produce the same bytecode:
// Without lambdas
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button pressed: " + e);
}
});
// With lambdas
button.addActionListener(e -> System.out.println("Button pressed: " + e));
Which one would you prefer*?
Note that this a feature that’s actually coming to Java real soon, but there are many other examples of Java verbosity that can be toned down without resorting to alien syntax or compromising performance.
[quote=“princec,post:34,topic:40839”]
I think the most interesting comparisons come from other JVM languages, not C/C++.
- I know that quickly writing an ActionListener is one shortcut away in modern IDEs, but the real issue is reading code, not writing it.