5 ms·
> Then there are language features in C# and Java, Typescript etc. that are coming across from Haskell. What language features in Java came from Haskell?
by chrisseaton 6y ago
> Then there are language features in C# and Java, Typescript etc. that are coming across from Haskell.
What language features in Java came from Haskell?
- quickthrower2 6y agoStream 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=...
- diablerouge 6y agoGenerics, no? Philip Wadler, one of the designers of Haskell, was involved with the introduction of generics to Java.
- chrisseaton 6y agoThe original paper on Java generics as we know them today only mentions Haskell twice, both times in passing. Once in reference to something that they didn't do (algebraic types), and once in reference to that both Haskell and their work were being inspired by an earlier common idea (System F) from the early 1970s.
- waltpad 6y agoI don't think these technologies are related: Java Generics is based on subtyping, however Haskell doesn't support subtyping (afaik).
- JoelMcCracken 6y agoLambdas?
- chrisseaton 6y agoBut those were popular and common before Haskell. Why would we say that lambdas spun off from Haskell to Java, rather than they were spun off from ML, or Miranda, or from Lisp?
- JoelMcCracken 6y agoI can’t say really, but my recollection is that the last decade of higher interest in FP has had Haskell as a fixture, and was significantly sparked by the need to program in a multi core world, and parallelization is made significantly simpler in the context of pure FP and controlled side effects. I hear you though. I was mostly a lisp person and only really got into Haskell in the last couple of years. Even still I would have said that the FP zeitgeist had Haskell as it’s central example of FP.
- lptk 6y agoI think it's safe to say that the inspiration for Java lambda almost certainly did not come from the "FP zeitgeist" you're describing, but simply from other JVM languages like Scala and Clojure, which showed how useful they were and how they could be done nicely on the JVM.
- JoelMcCracken 6y agoI believe both of those languages have motivational roots in the parallel computation drive/what I am describing as the FP zeitgeist. For example, this ya the earliest reference to clojure I could find on hn. Notice the text of the announcement and how it focuses on parallelism https://groups.google.com/forum/m/#!topic/comp.lang.lisp/xvKsMLKLL_k https://groups.google.com/forum/m/#!topic/comp.lang.lisp/xvK...