3 ms·
> works really well in Rust and TypeScript too And of course Rust and TypeScript were heavily influenced by Haskell... they just don't mention it and call thin
by dirkt 5mo ago
> works really well in Rust and TypeScript too
And of course Rust and TypeScript were heavily influenced by Haskell... they just don't mention it and call things differently, to avoid the "monads are scary, I need to write a tutorial" effect. Though it's less about monads and more about things like type classes.
Imitation is the sincerest form of flattery.
- Pay08 5mo agoAre type classes scary? PHP has had them since 2012.
- adastra22 5mo agoThey are different things.
- Pay08 5mo agoWhat are different things?
- zdimension 5mo agoEli5: Haskell type classes are not classes (like Java or PHP classes); they are comparable to Rust traits -- which are different from PHP traits which are comparable to Java/C# interfaces (with default impls; if you just want contracts you have... PHP interfaces). A fundamental difference is that you can instantiate/implement a type class (or Rust trait) for any* type, compared to interfaces where each class declares the interfaces it implements. You can therefore create generic (forall) instances, higher kinded type classes, etc.
- pjmlp 5mo agoThat conflates type classes with extension types, in type theory. Actually in modern Java you can simulate type classes approach with a mix of interfaces and default methods implementations. In C# you can have the experience more straightforward with extensions types introduced in C#13. Then we have yet another way to approach type classes in Scala, with traits and implicits. And so on, as I haven't yet run out of examples.
- derriz 5mo ago> Actually in modern Java you can simulate type classes approach with a mix of interfaces and default methods implementations. Can you? The beauty of traits/type classes is that you can attach them to any type - in a world where 90% of the functionality of any piece of software is supplied by dependencies - external types which you cannot change - this is a vital feature.
- pjmlp 5mo agoSimulate was the word, not map 1:1 the exact experience. It isn't pretty, but one can try to achieve a similar approach. https://godbolt.org/z/TjPha3obs https://godbolt.org/z/TjPha3obs Failing that, there are always Clojure, Kotlin and Scala on the JVM, which expose language features to achieve the same, which you naturally can mix and match with plain old Java.
- derriz 5mo agoWhy the reference to “modern Java” then? Writing adaptor classes is not “modern Java” nor does it involve using “a mix of interfaces and default methods implementations”. I was responding to your original claim and I’m well aware of such facilities in both Kotlin and Scala - having used both extensively. I was genuinely curious if the latest Java was in the process of adding support for trait/typeclasses - so I don’t understand why you’d bother to reply with something that completely changes your original claim.
- singpolyma3 5mo agoRust has typeclasses so that can't be it.
- cmrdporcupine 5mo agoRust's influence was OCaml, not Haskell. Its first compiler was written in OCaml. Its syntax directly looks like OCaml and C++ had a baby. It's got ML smells all over it. Haskell is not the sum of Hindley Milner-esque languages. Personally, never enjoyed Haskell's syntax (or lack of it) and tendency to overthinking. But I did enjoy SML/NJ and OCaml to some extent.
- deleted 5mo ago[deleted]
- metaltyphoon 5mo ago> heavily influenced by Haskell... they just don't mention it and call things differently Rust wikipedia says otherwise
- zelphirkalt 5mo agoAfaik Rust and Haskell both inherited from (S/Oca)ML.