From: Robert Klemme Date: 2010-07-20T14:25:03+09:00 Subject: Re: ruby abstraction On 20.07.2010 06:03, David Masover wrote: > On Sunday, July 18, 2010 02:35:03 am Robert Klemme wrote: >> On 07/18/2010 06:53 AM, David Masover wrote: >>> On Saturday, July 17, 2010 08:21:10 pm James O'Brien wrote: >>>> as a thought-experiment I >>>> propose Java without interfaces would be worse >>> >>> Probably. >> >> You could not have Java without interfaces. You would at least have to >> drop static typing and this would be a major change to the language. I >> don't think you would still call the result of this operation "Java". > > I don't think so. It would be much like Java without Generics -- frustrating > to work with, but possible. Basically, it kills any sort of polymorphism > between things which don't share a common ancestor -- so you make more use of > inheritance in some situations (take Collections, it wouldn't be so bad if we > had to inherit from AbstractCollection, AbstractList, etc), and aggressively > abuse modular decomposition (anywhere you have one object that needs to > pretend to be two types, make two related objects!), and you could make it > work. Still, that would not be the Java for me that we have today. Without interface a major feature for structuring code would be gone. Expressiveness of the language would be significantly changed. But you are right the language would resemble today's Java pretty much. > In fact, IIRC, this is how C++ does it -- it's just made much easier due to > multiple inheritance. I never quite understood why Java allows multiple > interfaces to be applied to the same object, and even to the same interface, > but not multiple inheritance. State. I guess they were afraid of the way C++ makes inheritance complicated because of virtual and non virtual inheritance and the consequences for the visibility of state ("diamond problem"). I would also add that "interface" is a cleaner concept because it stresses the fact that not behavior or state is shared but only the interface. Granted, you can achieve similar goals with abstract classes that contain only abstract methods but I think it was wise do have interfaces in Java. > I'm not suggesting this would be a good idea, mind you -- but then, I'm also > not entirely sure either Java or C++ is a good idea. LOL Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/