4 ms·
Stream API would be my first thought but I am not as familiar with Java. Maybe I should have said "ideas", I'm not sure there are any language level changes for
by quickthrower2 6y ago
Stream API would be my first thought but I am not as familiar with Java. Maybe I should have said "ideas", I'm not sure there are any language level changes for Stream API.
- chrisseaton 6y ago> Stream API would be my first thought but I am not as familiar with Java. Can you name any design characteristics in Java's stream API that came from Haskell, rather than were already common in many languages when Haskell itself was designed? I can't.
- atombender 6y agoJava's "stream fusion" is inspired by the same technique that was originally implemented, I believe, in Haskell [1]. [1] http://fun.cs.tufts.edu/stream-fusion.pdf http://fun.cs.tufts.edu/stream-fusion.pdf
- chrisseaton 6y agoBut Java doesn't do stream fusion as you're describing. It does conventional inlining and combining loop bodies, which can in some trivial cases achieve the same effect, but these are techniques you'd find in any compiler or even an 80s text book - they didn't come from Haskell. Here's the limitation of Java's 'fusion' - you'll notice there's no pass to do this in Hotspot - it just happens due to the inlining and GCM passes. https://github.com/openjdk/jdk/blob/883a4f65b9b1533c8a51d156640020ae0f87f263/test/micro/org/openjdk/bench/java/util/stream/pipeline/PipelineParMultiple.java https://github.com/openjdk/jdk/blob/883a4f65b9b1533c8a51d156... And here's a paper on trying to add actual Fusion to Java, which they wouldn't be doing if Java had it already. https://dl.acm.org/doi/pdf/10.1145/3355378.3355386?download=true https://dl.acm.org/doi/pdf/10.1145/3355378.3355386?download=...