So, I was thinking about taking some features a bit to the extreme, some "What if..." scenarios.
Say that I don't want to use "classical" inheritance at all. What would be the downside of relying on interfaces only?
First thing that comes to mind is the overhead of the vtables the JVM would have to use. Just skimmed over some things and seems like HotSpot uses a vtable for every kind of inheritance, but it still does more work for resolving abstract methods.
Second thing is repetition of code. If I say, well my IPosition GetX() method returns the position of the object in the X axis. It might aswell be exactly the same for 10 other classes that use that interface, but I'd have to implement it on every one of them separately instead of just inheriting the working method.
Instead of establishing a hierarchy of "Actor is a(inherits) SolidWorldObject" or "Actor has a(composition) SolidWorldObject" you'd have a "Actor implements SolidWorldObject" you could get rid of the hierarchy and be able to ask the Actor object directly for its position instead of asking to the SolidWorldObject inside the Actor.
On the other hand, everything using interfaces would make you able to do some cool stuff, like grouping things in collections without worrying of "can I cast this to that, is that child or parent of that other class" and so on.
It would make easier to get a more "data oriented" design with huge collections of objects and the program iterating over them with the same interface, again, without the obtuseness that some class hierarchies might have.
And other thing I thought is if it would be any different to replace all instanced object methods with static methods that have a reference as parameter.
Say, instead of calling vec.normalize(); You'd call, Vector4f.normalize(vec); Instead of calling player.getX() You'd call Actor.getX(player);
The object would only hold data whereas the class would hold the static methods to operate on such data.
I'm not quite sure but I guess that's how method calls are implemented when they're compiled. While the per-object method calls gives you a nice way to relate the method call with the object you're using. So I guess you'd be doing "compiler work" by doing the reference passing by yourself instead of relying of the per-object method call and the "this" keyword.
It all came out of me thinking what could I do to make my math library better (something I might ask for more directly on another thread). What do you think?