News for hackers. Stuff that matters.
Re:Data-oriented design or why you might shoot yourself in t... by heavyset_go on Monday June 28, 2021 @04:50PM (#27667916)
> Polymorphism is good. You describe polymorphism.

It also seems like they're describing the nominal typing of Java versus a structural approach.

Re:Data-oriented design or why you might shoot yourself in t... by nine_k on Monday June 28, 2021 @08:33PM (#27670171)
Haskell 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.

Re:Data-oriented design or why you might shoot yourself in t... by AdieuToLogic on Tuesday June 29, 2021 @12:05AM (#27671646)
> 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

Re:Data-oriented design or why you might shoot yourself in t... by heavyset_go on Tuesday June 29, 2021 @05:48PM (#27682147)
I'm unfamiliar with anything like that in Rust, beyond Rust's structural approach to tuples. I'd love to hear more about it, though!
Re:Data-oriented design or why you might shoot yourself in t... by SAI_Peregrinus on Friday July 02, 2021 @10:47AM (#27712197)
I 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...