Re:Representing the Impractical and Impossible with JDK 10 “...
by akerro on Sunday March 04, 2018 @04:08PM
(#16516746)
Well, I don't like streams in Java, they make code much slower, it looks fancies, but in real time, streams are often abused and make code run longer in almost every case I measured (I took some methods from Github, SO and reddit comments). Equivalent for loop/for-iterator loop is much faster. Solution: you don't have to use it, you can educate others how to use it properly.
[ Parent
| on HN ]
Re:Representing the Impractical and Impossible with JDK 10 “...
by Amelorate on Sunday March 04, 2018 @05:14PM
(#16517098)
It is possible for a compiler to optimize long method chains into the equivalent imperative code. The rust compiler is an example, and in the case of the iterator trait, it can actually be optimized better than the equivalent imperative code, by removing checks when indexing into the array.
Re:Representing the Impractical and Impossible with JDK 10 “...
by Thiez on Sunday March 04, 2018 @05:21PM
(#16517129)
The default Java compiler doesn't do much optimizing. This is intentional, so there would be incentive to make the JVM really smart (a great decision, I think). But it's possible that the JVM doesn't optimize streams that well at this time.
Re:Representing the Impractical and Impossible with JDK 10 “...
by vbezhenar on Monday March 05, 2018 @06:26AM
(#16520303)
Do you have any benchmarks for particular slow use-cases? I used to think the same, but in my quick benchmarks streams were as fast as handwritten code (may be a bit slower, but not much slower).