IntStreams and the case of the missing reduce
Brent Walker
brenthwalker at gmail.com
Tue Jan 7 06:57:21 PST 2014
Look at the example code I gave in my original email. Are you seriously
proposing I create a "new Integer" every time through the loop? What if I
am doing numerical code, if my loops are nested etc etc... By your logic
let's just delete IntStream, DoubleStream, and LongStream and be done with
it. That's possible but primitive streams are kind of cool. Code is
succinct, streamlined and can be parallel at little effort.
The dirtiness you speak of came from years back when Java was designed with
a type system that looked like the C++ type system. But that's ancient
history.
Given all that baggage, building the streams library was an exercise in
compromises -- we all get that. All I am saying is that in this particular
case (of the missing reduce) we have introduced a new dirtiness for no
reason at all.
Now not only is "int" different from "Integer" in the ways that we all know
and hate, but also IntStream is different from Stream<Integer> in one more
way... some functions are missing.
Maybe in Java 9 we will get a unified theory of everything and this
discussion becomes moot but until then we have to deal with one more wart
and it is a shame.
Brent
More information about the lambda-dev
mailing list