Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>>OO folks are wasting their time discussing minutiae of their little peculiar use case, such as, say, single vs. multiple inheritance, while at the same time nobody is paying attention to what is needed in majority of cases.

Maybe they were fifteen years ago, I don't think that is the case now, the two most popular OO languages (Java and C#) don't even support multiple inheritance.



Well, they do, kind of. Just that multiple inheritance is only allowed with the use of interfaces. In C++ multiple inheritance is supported, and interfaces are actually pure virtual abstract base classes. And that's what interfaces in Java (and C#, I think) are, just with the addition of some compiler checks for interfaces. Please correct me if I'm wrong, though.

I seldomly use mutiple inheritance in any language, and instead prefer composition.


True. We use composition to attach things to an object rather than develop a deep taxonomy through inheritance.


well, with default implementation in interfaces, now java support (something resembling) multiple inheritance


I think you and tonyedgecombe have different definitions of support. In my understanding, default implementation was included to allow adding methods to interfaces without updating the classes that implement them. You can use this feature to do something like multiple inheritance, but I haven't heard anyone recommend it.


Well, I hardly know anyone recommend multiple inheritance, whatever the language is :D




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: