Re:Map.merge() – One method to rule them all
by _old_dude_ on Sunday March 31, 2019 @03:32PM
(#19537779)
It's also to separate the methods doing computation lazily (Stream) from the one doing computation eagerly (Collection).
Otherwise a simple call like isEmpty() can trigger the whole computation like in Haskell.
As a user of the API, you have to wrap your code into a Stream to be lazy evaluated, the Stream being a computation monad, so you always know if a code is evaluated eagerly or lazily.
Re:Map.merge() – One method to rule them all
by jnordwick on Sunday March 31, 2019 @11:45AM
(#19536149)
> modern functional methods like map/reduce/filter/group
"Modern". Lol.
Re:Map.merge() – One method to rule them all
by vbsteven on Sunday March 31, 2019 @12:03PM
(#19536282)
I know these functional concepts are far from new.
I use "modern" in this context because other contemporary languages like Python/Ruby/Scala/Rust etc all have versions of those and FP-style collection usage using these names has become popular in the last 10 years.
Default methods on interfaces help to add features to existing collections but they are limited in what they can do, hence streams.
If you really want more ergonomic collections while staying close to Java then use Kotlin which can be easily added to most Java code bases and has all the modern functional methods like map/reduce/filter/group on standard collections.