3

Recently, I've stumbled upon an old interview with Dennis Ritchie, Bjarne Stroustrup and James Gosling, published back in 2000. Each of them talked about the language they were most involved with, namely C (Ritchie), C++ (Stroustrup) and Java (Gosling).

It's a very interesting article in itself, but what caught my attention in particular was the following quote from Gosling (emphasis mine):

Q: If you could go back in time, knowing what you know now, what might you do differently in designing Java? Why?

A: There are a bunch of things that I'd do differently. There are a number of things that I'm not entirely happy with and it's not clear what the right answer is. I'm not really happy with the schism between interfaces and classes; in many ways it feels like the right solution wouldn't get in the way. [...]

He hasn't elaborated on this "schism", but it's quite obvious (at least to me) that his answer related to the design of the Java language itself in some way.

So what did Gosling mean with the quote above, and has that situation changed during the last 18 years since the interview was published?

  • 1
    I would say this is opinion-based unless James Gosling himself answers. Maybe try asking him directly? – Euphoric Oct 9 '18 at 10:03
  • 4
    Did you realize that C++ does not have a distinction between interfaces and classes? This seems relevant in the context of the interview. Back in 2000, the dumbing-down of Java was a controversial decision. – MSalters Oct 9 '18 at 12:10
  • @MSalters: could you elaborate? Seems like good material for an answer. – Miroslav Cetojevic Oct 9 '18 at 15:09
  • Interesting. Considering that Objective-C was the major influence on Java, is based heavily on C, and is a competitor to C++, it seems strange that Brad Cox and Tom Love are not included in that interview. To me it seems that Objective-C fits much better together with Java and C++ than C does. Oh well. I suppose, they won't re-do the interview 18 years later, just to please me :-D – Jörg W Mittag Oct 9 '18 at 19:28
5

Based on other times he has talked about it, I think what he is referring to is that interfaces are necessary to solve a problem with classes that in theory classes shouldn't have to begin with. Classes are supposed to give you the ability to create a more abstract interface defined by the base class, and extend that into a more specific interface through inheritance. Interfaces are only really necessary when that whole process doesn't work, such as in multiple inheritance situations because Java intentionally does not support multiple inheritance for classes.

I think what Gosling meant was that he never figured out how to get classes "right" in such a way that Java could get away with not having interfaces in the first place, because all of the functionality of interfaces would be built into classes themselves. Class inheritance in general is something that he has mentioned is a flaw in Java, and I think many software developers in general agree that class inheritance can be problematic in many situations. One of the ways he mentioned of possibly solving this would be to focus more on delegation over implementation inheritance, but as in this interview most of the times he described it as a problem that he never figured out a good solution for.

|improve this answer|||||
  • So, basically Gosling wanted to avoid overuse of class inheritance but could never quite figure out how, without getting rid of it altogether? – Miroslav Cetojevic Oct 9 '18 at 19:27
  • The Go Language has solved this problem by basically making every class its own "interface," and then using duck-typing to glue together the necessary method invocations. See tour.golang.org/methods/10 – Robert Harvey Oct 9 '18 at 21:03
  • @RobertHarvey: that sounds and looks kinda neat. In the example you linked, is the interface available for other classes, too? – Miroslav Cetojevic Oct 9 '18 at 22:05
  • Yes, it works for all user-defined types. – Robert Harvey Oct 9 '18 at 22:27
  • @RobertHarvey: Where did Go get the inspiration for this? Surely it couldn't have been the first to let classes use interfaces via duck-typing? – Miroslav Cetojevic Oct 9 '18 at 22:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.