views:

261

answers:

6

I know about C++ pure virtual classes, but Java went one step further and created a first-class (no pun intended) concept for multiple-interface (not implementation) inheritance, the interface. It's now a staple of major statically-typed languages. Did Java invent the interface concept? Or did it appear in older languages also as a first-class concept?

+1  A: 

pure virtual classes without fields were called in C++ interfaces even before Java. Idea behind Java's interfaces was to remove nasty multiple inheritance as it was in C++, but leave similar capabilities.

Andrey
A: 

I'm quite sure that Java developers didn't invent the concept of interfaces but they popularize them.

Crozin
+2  A: 

As far as I know Objective-C was the first language to feature interfaces. At least it had them before Java was invented.

ahe
I don't know Objective-C, but by its wikipedia entry, it seems that its `interface` is more related to a forward declaration of a specific class interface (like a C++ header file), and not to the Java interface concept. Please correct me if I'm wrong!
Jordão
Of course, but the 'interface' concept is called 'protocol' in Objective-C.
Dave Van den Eynde
A: 

IDL, used by CORBA, I believe goes back to the early 80's.

Tom Hawtin - tackline
Yes, but IDL is not part of a language, but of a specification for language interoperation. But you're right, it might have influenced the Java interface concept in some capacity.
Jordão
@Jordão IDL is not a programming language. It is however a language (that is the L bit).
Tom Hawtin - tackline
+10  A: 

Here is abstract from the article The Java Language Environment.

An interface in the Java language is simply a specification of methods that an object declares it implements. An interface does not include instance variables or implementation code--only declarations of constants and methods. The concept of an interface in the Java language was borrowed from the Objective-C concept of a protocol.

http://java.sun.com/docs/white/langenv/Object.doc2.html#6185

Shaji
+2  A: 

I'm pretty sure IUnknown and IDispatch existed before Java... But that's COM, which isn't really a language.

Jacob G
Same thing with CORBA.
Jordão