Subclassing vs Interfaces

It is good to see that some old ideas are still kicking around. I’ve been reading more threads about people trying to recreate Genera, the old Symbolics lisp environment on a modern day cpu. Apparently, and unsurprisingly, the open source community is having a hard time coming up with anything better. The old ideas are still better, and are slowly being rediscovered.

The same will be true for OO. In a recent article, a new kid on the block states: Inheritance is evil and must be destroyed. Ignore the pretty flowers and butterflies on his blog… this is war and this guy is a warrior. Or he is just using the ‘let me shout heresy’ technique to get readers. Either way I read his talk.

Here is my take. Anybody who has done a lot of OO work will learn that they don’t subclass as much when they are building ‘real apps’. There is a reason for that and it is covered in the article. I do think that the author gave a great description, but he misses a lot of the history on this. Javascript, which is prototype based, borrows more from Lisp and Self than Java. In Self and LISP, the concept of a ‘mixin’ is much more prevalent than in other languages. Of course, even in those languages, when people learn OO, the inheritance and subclassing are drilled home very early on.

Anyways, the main point I’m trying to make is this. The ideas are old. In fact, if you look at Microsoft COM, which came from old DEC guys in the late 80’s and was deployed in the mid 90’s… it was completely based on the concept of interfaces and mixins. Unfortunately, they had to make that work in C++, so most of the new programmers will never see these old ideas behind the C++ complexity and hacks.

I remember talking to Steve about this a while ago. He noticed it earlier than I did. It is probably one of the things that led him to the path of prototype languages. It is an interesting topic and I think there is new ground to be broken in understanding them. I don’t necessarily think ‘patterns’ are the right way to describe them. They tend to look like workarounds to limitations in languages more than generic patterns (think Java and C++). What I would like to see is a great description on mixin architectures. What makes them work … or not work? How do you design them?

BTW, why aren’t the old ideas out and copied more often? I think a lot of this has to do with how expensive some of these old systems used to be. If you wanted to use Smalltalk or a Nexstation, you better have a serious budget for machines and software. As a result, only the relative few good devs were justified the cap-ex. So if only a few people had access, and only a few of them were great communicators.. a lot of interesting ideas will sit on old tapes. I also think the open-source community under estimates the cost of copying some of the great old ideas. The net result is that old-ideas have to be rediscovered.

This entry was posted in General. Bookmark the permalink.

2 Responses to Subclassing vs Interfaces

  1. Ignore the pretty flowers and butterflies on his blog… this is war and this guy is a warrior.

    Aw shucks, you just made my day.

  2. Michael says:

    No this is certainly not new. It immediately reminded me of Alan Holub: http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html

    Holub’s point was that subclassing implementation classes is bad but interface inheritance is good. From the examples by Bernie, it looks like he would agree.

    You should write more about your “mix-ins” ideas. They seem similar to the GOF Strategy pattern that Bernie was clearly making use of.

Leave a Reply

Your email address will not be published.