LWN.net Logo

Everything to like

Everything to like

Posted Mar 30, 2005 12:44 UTC (Wed) by Zarathustra (guest, #26443)
In reply to: Everything to like by pkolloch
Parent article: Evidence that Python is advancing into the enterprise (NewsForge)

There is a big difference between features that can be abused but that can be used properly with some care, and that don't get in the way(eg., C pointers, goto), which is perfectly fine and in many cases a sign of good language design; and features that encourage abuse or that are almost impossible(if at all) to use in sane ways, and that add gratuitous complexity to core parts of the language(eg., multiple inheritance, auto-boxing, "checked exceptions", cpp).

I have yet to see anyone using multiple inheritance in any justifiable way and without ending up with a big mess. And what is worse, MI brings with it an insane amount of complexity into any language that implements it, just look at Python's MRO, it's nauseating the kinds of hacks people puts into their languages to have MI.

Also is not enough not to use MI yourself, as APIs and libraries implemented by naive programmers often force you to use inheritance, mixins are one of the worst ideas I have ever seen, they might seem like a cool hack at first, but end up interacting in unpredictable ways and sending you flying into a world of pain and close coupling among bits that have nothing to do with each other.

And this is not to mean that Single Inheritance is any good either, but at least makes sure that the hierarchies remain within a minimum of sanity, and doesn't force the language to include so many hideous hacks just so it can handle the retarded mess of inheritance models that are possible with MI.

In the end, in a language with a decent type system, inheritance buys you nothing except pain, even the most radical OO zealots, if they have a clue, will tell you to use composition over inheritance if possible, and let me tell you, unless some retarded API forces you or you use a really braindamaged language(eg., Java) you can always do things perfectly fine and with much less trouble without inheritance.

I will finish with the wise words of Rob Pike:

"Object-oriented design is the roman numerals of computing"


(Log in to post comments)

inheritance != object oriented

Posted Mar 30, 2005 12:57 UTC (Wed) by zooko (subscriber, #2589) [Link]

I agree with you that inheritance is used way too much. I would be just as happy in a language without inheritance, and when I code in a language with inheritance, I try to avoid it as much as possible. (Such as, to be topical, Python, where the dynamic and structural object oriented make it easy for me to accomplish what I want without using Python's builtin inheritance.)

But inheritance != object oriented. Modern object oriented languages like E don't have inheritance.

inheritance != object oriented

Posted Mar 30, 2005 17:48 UTC (Wed) by Zarathustra (guest, #26443) [Link]

It depends what definition of "Object Oriented" you use. I(and I think rob) was trying to use the most "popular" definition, which probably is not the most accurate.

It has been argued that Limbo is object oriented done right. It has even been argued that Plan 9 is object oriented OS, where files are objects that have a well defined interface.

But in general by OO people understands Java, C++, and if you are lucky, Smalltalk.

By the way, E is quite interesting, I would like to use it for some project, I wonder how it compares with 9p/Limbo and Erlang.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds