标签云

微信群

扫码加入我们

WeChat QR Code


COM is not a language. Interfaces are a feature in the language.

2018年09月26日33分06秒

Can you elaborate a bit more?

2018年09月26日33分06秒

Java got the idea of interfaces from Objective-C: cs.gmu.edu/~sean/stuff/java-objc.html

2018年09月27日33分06秒

IDL had interfaces way before Java

2018年09月26日33分06秒

Java was not the first language to add explicit support for interfaces. They existed as an explicit language keyword as early as 1986, in the language Modula-3 (see my post below for more details).

2018年09月27日33分06秒

It's amazing how wrong the other answers are... I think strictly speaking SmallTalk -> Objective C -> Java.

2018年09月26日33分06秒

Yes, but they were not a language feature.

2018年09月26日33分06秒

Technically, interfaces were a language feature. They were defined semantically (create a class under these conditions and the compiler will emit code that corresponds to that binary interface). The fact that the feature is semantic, and not syntactic, doesn't make it less of a feature.

2018年09月26日33分06秒

Also, they were syntactic features of the COM and CORBA interface definition languages, which were languages designed specifically for defining interfaces. In any case neither C++, MSIDL,or CORBA (which predate Java) were the first languages to offer such features. They have been around "forever".

2018年09月27日33分06秒

Interfaces are more limited than virtual base classes, and for good reason. For example, you cannot apply polymorphism to an interface.

2018年09月27日33分06秒

I believe you can extend interfaces in C#. Haven't tried it in Java yet. I don't know if that is the type of polymorphism you're referring to.

2018年09月27日33分06秒

They don't abstract anything. They are a strict ruleset that a class must follow.

2018年09月27日33分06秒

They abstract what is actually going on. The interface sets up a strict ruleset only on semantic interfaces, no guaratee on what is going on in the implementor.

2018年09月27日33分06秒