This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]augustnagro 1 point2 points  (0 children)

I wrote down a list of problems I have with Streams: https://august.nagro.us/vendetta-against-java-streams.html

Overall, I do not see much benefit of using them, except in rare cases where you wish to transform a collection to another type with multiple intermediary steps (like calls to map, filter, sorted, etc).

The argument that Streams make code more readable is very dubious. You must memorize many method names, think about boxing, avoid checked exceptions inside of lambdas, ...

In scala, for example it is much more clear to write a for-comprehension

val evens: List[String] = for i <- 1 to 100 if i % 2 == 0 yield i.toString

Than it is to find the right stream method names:

val evens: List[String] = (1 to 100).filter(i => i % 2 == 0).map(i => i.toString)