Live data from Hacker News

Java 8: No more loops

deadcoderising.com

1–10 of 99 posts

Re: Java 8: No more loops

#5
The first example is actually a poor way to do it, IMO. Even if behind the scenes, these are implemented lazily (like C# LINQ), it may not be obvious what's going on to someone else who isn't familiar with the API. I'd opt for the for() loop each time when it's something like halting when you find what you're looking for.

Re: Java 8: No more loops

#7

I really want to like functional programming, but the functional version of each of these seems less readable and more verbose.

I guess this is why Microsoft diverged from the "standard" names like 'map', 'collect' and 'filter' in favour of more human-oriented SQL-like LINQ: 'select', 'where', 'toList'.

I have to read the underscore.js documentation every time I am using it :(.

Re: Java 8: No more loops

#8
post #7

I really want to like functional programming, but the functional version of each of these seems less readable and more verbose.

I guess this is why Microsoft diverged from the "standard" names like 'map', 'collect' and 'filter' in favour of more human-oriented SQL-like LINQ: 'select', 'where', 'toList'. I have to read the underscore.js documentation every time I am using it :(.

MS did the right thing. A huge barrier to FP adoption is the unnecessarily obtuse terminology. In playing around with FP languages I often find myself having to re-look-up basic syntax because the terms are simply so obtuse that they won't "stick" in my head.

I think it comes from FP's rooting in mathematics, and math is itself unnecessarily arcane.

Re: Java 8: No more loops

#10

I really want to like functional programming, but the functional version of each of these seems less readable and more verbose.

This was exactly what I was thinking when I read the code. The goal should not be to remove loops. As a language construct there is nothing wrong with loops itself. The goal should be to make more readable and maintainable code, preferably without increasing verbosity. The functional alternatives posted here are not actually code quality improvements and should not be presented as such.
Post reply on HN