4 ms·
It doesn't restrict gigantic hierarchies per se, just the compiler won't help you there.
by zerr 7y ago
It doesn't restrict gigantic hierarchies per se, just the compiler won't help you there.
- throwaway894345 7y agoThere isn’t inheritance, so there are no hierarchies in the problematic sense.
- apta 7y agoYou get problems like this, which you don't get in traditional OO languages: https://github.com/golang/go/issues/16474 https://github.com/golang/go/issues/16474
- throwaway894345 7y agoWhat are you talking about? You could do exactly this in Java or C# or Python or Ruby or JS or etc. Not sure what ”traditional” languages you’re talking about, but this is just reflection and downcasting. It’s a bad idea, but it’s unrelated to OOP.
- apta 7y agoYou can't cast a type to an arbitrary interface and hope that it implements the method(s) you want to call in Java or C#.
- throwaway894345 7y agoThey aren’t “hoping it implements an interface”, they use reflection to determine whether or not the type implements the interface. This is pretty much the same thing in Java or C# with reflection and downcasting, but it’s a bad idea in both languages.
- pjmlp 7y agoSure there is, spaghetti interface implementations, even types that happen to implement interfaces that they didn't intend to, with methods that happen to match the signature, having completely different semantics.
- throwaway894345 7y agoThose aren’t hierarchies as I understand them, nor do I understand those to be real problems (I’m sure someone has been bitten by one of those but only by the law of averages).
- pjmlp 7y agoOOP is not Java.
- throwaway894345 7y agoI don’t see how that’s relevant.