Poll Result: Most Consider Lambda Expressions in Java a Good Idea; Some Disagree
The results of the latest completed Java.net poll indicate that, in general, developers consider the addition of Lambda Expressions (closures) to Java (which will happen in Java 8) to be a good idea. However, opinion is not universally in this direction. A total of 401 votes were cast in the poll. The exact question and results were:
Is adding Lambda Expressions (closures) to Java a good idea?
- 48% (192 votes) - Of course! We've needed this for a long time!
- 15% (59 votes) - Probably
- 6% (25 votes) - Maybe
- 2% (7 votes) - No, threads and the Fork/Join Framework are sufficient
- 14% (55 votes) - No, because they'll be misapplied, complicating lots of code
- 11% (43 votes) - I don't know
- 5% (20 votes) - Other
First, my normal disclaimer: these are the results of a voluntary survey, not a scientific poll. Still, I think the results reasonably reflect the attitudes of Java developers. While about half of the voters think Lambda Expressions in Java have been long overdue, significant skepticism is also evident. Combining the "Probably," "Maybe," and "No" results yields 37% of developers expressing at least some doubt about whether adding closures to Java is a good idea.
Now, you can think adding a new feature to a language is a good idea even if you yourself are unlikely to use that feature frequently. But, to have doubts about whether adding a major new feature to a language is a good step -- that's an entirely different matter. In this poll, 14% actually believe the addition of Lambda Expressions will be, on balance, harmful, because some developers will apply the shiny, glitzy new capability in situations where there's no sensible reason for doing so.
Java Champion Kirk Pepperdine, a Java performance expert, has often stated that complex code can easily produce performance bottlenecks. For example, in this 2009 interview with Janice Heiss, Kirk states:
Brian Goetz and other influential developers have been saying for some time that if you write overly complex code, something's wrong.
I can cite example after example where the act of simplifying code allowed us to get the performance that we needed. Surprisingly enough, this principle actually goes beyond languages, so some of the biggest gains I've seen have been in applications where we simplified Smalltalk code.
In the Java language, it becomes doubly important because now we have runtime optimizations being applied to the code, and complex code confuses the optimizers. When you confuse the optimizers, they do not do a good job of optimizing, so you have a couple of problems with Java when you write complex code.
Kirk also highlights the need to measure performance, not just guess. The entire purpose of Lambda Expressions is to enhance performance on multicore devices. But, if you don't understand Amdahl's Law, you can easily waste lots of development time and effort writing overly complex code that either minimally improves performance, or even degrades overall performance. And, on top of it all, when the original developer leaves the company, successive developers who need to maintain or upgrade the code are faced with something that's basically unreadable, and readily susceptible to being broken by the tiniest modification.
This, I think, is the kind of thing that has many concerned about the Lambda Expressions enhancement that's coming in Java 8.
Still, what choice is there? The design of Java's Lambda Expressions will simplify the porting of legacy applications such that they can utilize multiple cores in modern devices. To not parallelize the key computational components in these applications will ultimately lead to their death due to horrid performance compared with competing apps written in other languages that support parallelism. It's the proverbial double-edged sword (something that "cuts both ways").
Lambda Expressions are a benefit (in the hands of excellent programmers), but also a liability (in the hands of less talented / less experienced developers). But, in my view, they are absolutely needed, because of the Multicore Challenge.
Opinions on closures in Java, circa 2006
Shortly after I posted this poll, my Java.net editorial predecessor and friend Chris Adamson tweeted about the fact that he ran an almost identical Java.net poll back in 2006! That poll asked "Would you like JDK 7 to support closures?" 41% said yes, 21% said no, 10% said they weren't sure, and 27% didn't know what a closure is. Again, while Java.net polls aren't scientific, I think this implies that even six years ago a lot of people had doubts about adding closures to Java.
More people today are in favor of having Lambda Expression support in Java. This makes sense given the explosion of multicore devices in the intervening years -- even down to quite small hand-held devices. And the multicore trend will likely accelerate in the coming years, rather than diminish, due to the already-in-progress demise of Moore's Law.
New poll: Java DB improvements/enhancements
Our new Java.net poll asks What new feature or improvement would you most like to see in Java DB?. Voting will be open until Friday, June 22.
- Max Bonbhel, JCertif 2012 - Call For Paper : The biggest Java/Android Community Event in Africa;
- Evan Summers, Counter map;
- Cay Horstmann, Wildcards in the Wild;
- John Ferguson Smart, Want to become a JAVA master?;
- Larry Fernandez, The Greatest Question\Riddle of Them All?; and
- Sonya Barry, 2012 Duke's Choice Award Nominations close Friday.
Here are the stories we've recently featured in our Java news section:
- Arun Gupta notes JAX-RS 2.0 Early Draft - Third Edition Available;
- Dustin Marx collates Early JavaOne 2012 Abstract Acceptances
- Geertjan Wielenga shares Two Hidden NetBeans Keyboard Shortcuts for Opening & Toggling between Views;
- Francois Roland shares Fork/Join and Akka: parallelizing the Java platform BeJUG conference;
- Geertjan Wielenga demonstrates View Clipboard & Copy To Clipboard from NetBeans IDE;
- Bob Rhubart presents Podcast Show Notes: Public, Private, and Hybrid Clouds;
- Joseph D. Darcy details Moving monarchs and dragons: migrating the JDK bugs to JIRA;
- James Sugrue demonstrates Clojure Expectations Colorized;
- Bob Rhubart presents Community Roundtable: Agility versus Architecture;
As I've previously reported in this blog, we planned three JSRs to improve the JCP’s processes and to meet our members’ expectations for change. The first - JCP.next.1, or more formally JSR 348: Towards a new version of the Java Community Process - was completed in October 2011...
Previously we featured Charles Humble's Martijn Verburg on the London JUG, the JCP and Oracle's Handling of the Java Community:
Interview with Martijn Verburg, who co-leads the London JUG (a JCP EC member), and runs a couple of open source projects. He's become a regular speaker at conferences on Java, open source and software development and has recently published his first Manning title - "The Well-Grounded Java Developer" with his co-author Ben Evans....
Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.