3 ms·
> Polymorphism is good. You describe polymorphism. It also seems like they're describing the nominal typing of Java versus a structural approach.
by heavyset_go 5y ago
> Polymorphism is good. You describe polymorphism.
It also seems like they're describing the nominal typing of Java versus a structural approach.
- nine_k 5y agoHaskell and, IIRC, Rust allow you to declare that a certain data type conforms to some interface, and describe how, by listing / adding the functions with necessary signatures. This allows to have the upsides of structural polymorphism without losing static checks. Go, OTOH, goes all the way structural.
- AdieuToLogic 5y ago> Haskell and, IIRC, Rust allow you to declare that a certain data type conforms to some interface ... I believe at least in the case of Haskell, you are referring to type classes[0]. 0 - https://wiki.haskell.org/OOP_vs_type_classes https://wiki.haskell.org/OOP_vs_type_classes
- heavyset_go 5y agoI'm unfamiliar with anything like that in Rust, beyond Rust's structural approach to tuples. I'd love to hear more about it, though!
- SAI_Peregrinus 5y agoI think they're just talking about how you have to declare what trait a function implementation is for, rather than having it derived from the type signature alone. The `impl Trait`[0] syntax. In Go, you don't need to declare that the function implementations are being implemented for a particular interface, you just have to match the type signatures and function names. Rust's way can help avoid some errors. You can't accidentally implement an interface, whereas in Go you can if you happen to implement a group of functions with appropriate names and type signatures. It's unlikely to cause actual bugs (you'd have to misuse the resulting implementation) but can be conceptually somewhat confusing. [0] https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits https://doc.rust-lang.org/book/ch10-02-traits.html#returning...