views:

142

answers:

3

I'm aware that most things in modern programming languages are at least partially based on features in earlier languages.

This leads me to wonder where java got the inspiration for interfaces from. Was it mostly their own creation? Was it based on fully Abstract Base classes(with multiple inheritance) ?

+7  A: 

In a recent Objective-C book I was reading Learn Objective-C on the Mac, the authors suggest that the primary inspiration for Java's interfaces are from Objective-C's implementation of Formal Protocols.

Formal Protocols in Obj-C are files, just like Java's Interfaces, that are filled with abstract methods – or plainly just the method headers – that the developer must implement if the Formal Protocol is used. In the most recent update to Apple's Cocoa, Formal Protocols can also include optional methods which the developer doesn't need to implement if the class implements the protocol.

Sean
The Java design team knew the Objective-C design team very well, and later when NeXTStep started circling the drain, a lot of them jumped ship and joined Sun. Protocols are not the only thing they took from Objective-C, indeed the entire object model and even pretty much the entire language are taken from Objective-C. Java is pretty much Objective-C - C + GC.
Jörg W Mittag
I though the object oriented parts of Objective-C were dynamically typed?
Roman A. Taycher
A: 

Actually It comes from the idea of multiple inheritance and abstract class. Our dear Mr. Goslin did not wanted the multiple inheritance in class level.

Barun
+6  A: 

I think the designers of Java realized that there are a lot of flaws in using multiple implementation inheritance, but still wanted to be able to multiply inherit. Thus, the solution was multiple interface inheritance.

Also, from the previous link:

Instead, Java's designers chose to allow multiple interface inheritance through the use of interfaces, an idea borrowed from Objective C's protocols. Multiple interface inheritance allows an object to inherit many different method signatures with the caveat that the inheriting object must implement those inherited methods.

So, Sean is indeed correct.

Mike