Until now, i believed, an interface is like going to Steve's Ice Cream and just looking in the window. (Steve's is where the Lisp terms "flavors" and "mixin" came from.) However, I'm beginning to agree with Dan that the concept of an interface can be useful even in Common Lisp. I think we used the term "protocol" for a group of methods that work together, which is the essential idea. I did an analysis of one Lisp system, and 3 Java systems to get some idea about how interfaces, in Java, and mixin's in Lisp are used. The Java data supports Anton's claim that interfaces are widley used. In fact, 70-75% of the classes implement one or more interfaces. While AMP, the Lisp application, has about the same relative percentage of mixin's as JDK 1.4 has interfaces, its use of multiple inheritance seems fairly low, at first. However, the top 5 most popular interfaces to implement tend to be either Serializable, a Listener, or Runnable. In Lisp, Serializable is implemented by a method which is just written for the class if necessary. Listeners and Runnables are simply procedures in Lisp, not classes. Further analysis could reveal interfaces struggling to get out of the Lisp code, and multiple inheritance and closures struggling to get out of the Java code. k At 02:12 AM 8/8/2002, Anton van Straaten wrote: > > While I agree that interfaces are important in Java, i miss mixins and > > multiple inheritance as in Common Lisp, for example. In Java you need to > > implement the interface over and over. > >Oh definitely. Not having support for any implementation reuse mechanism >other than single inheritance is a harsh restriction, in a system that >supports multiple interfaces on classes, and I'm sure it inhibits use of >interfaces in Java. I didn't mean to imply that Java was unassailable in >this respect, but if you don't look to closely at the implemenation side of >things ;) it's an example of the interface-oriented approach having >succeeded in practice. > >Many people unfamiliar with Java don't seem to be aware of the approach, or >its possibilities. Even if they're familiar with it in dynamically-typed >systems, they may not have seen it in action with static typing. > >As for reuse of interface implementations, you seem to have some Lisp code >to read Java classes - can't you use that to generate Java classes, too?? >;o)) > > > Your message made me curious about how interfaces are actually > > used in Java. > > Here's what i found by scanning JDK1.4's rt.jar: >... > > Other jars could have a higher interface ratio, and certainly user code > > might have more concrete classes that implement those interfaces. > >I suspect that some of the third-party libraries out there might have >heavier use of interfaces, and I also have the impression that newer JDK >code uses them more heavily than was done in earlier code that's still >present in the JDK. My experience is that in "modern" Java programming (as >opposed to the dark ages back at the dawn of time, around 1996), interfaces >are being used pretty commonly and appropriately. > >Anton
Attachment:
mixin.data
Description: Binary data