3 ms·
The comments in this thread baffle me. I find it amazing that some Java programmers are so rigid in their thinking that they can't deal with the introduction of
by cromwellian 14y ago
The comments in this thread baffle me. I find it amazing that some Java programmers are so rigid in their thinking that they can't deal with the introduction of high order function types that practically every other programming language has.
One of the reasons why it's taken so long for Java to get these features was early arguments by members of the JCP that, quite literally, Java programmers were too scared off by the "complexity" of closures. Which is ironic because I see forum postings from Java programmers looking down on Javascript/Ruby and other scripting languages as for less-rigorous/serious engineers.
Soft bigotry of low expectations? How can Javascript programmers do fine with the complexity of closures (without types!), but Java programmers are a kind of special protected class of wimps that have to be shielded from functional programming of any sort? :)
Lambdas, Streams, and other high order constructs produce vastly more readable code and encourage additional re usability through more abstraction. If you think the introduction of "for-each" in Java5 was a good thing, why be opposed to collection.forEach((x) -> expr), if you can understand for(T x : collection) expr; ? Ditto for listener patterns, filters, comparators, runnables, futures, concurrency primitives, parallel streams, all are easier to use and understand with lambdas.
If takes only a few hours and one or two samples to get used to the new lambda syntax, especially if you are familiar with HOF in JS/Ruby/Python/Perl/C#/every-other-freakin-language.
- hp50g 14y agoI think its a different culture. Both approaches are valid. The issue with closures and lambda syntax for java developers is probably around the fact that it is in most cases 100% unnecessary and doesn't really add anything to the product you're building. Even our core product which is c# is devoid of such things, not because we don't know about them but because we don't need them to drag stuff out of a database and throw it on a web page. Just because closures and lambda functions are an awesome hammer, it doesn't mean every problem is a nail.