3 ms·
I think the key to the success of Java's flavor of OO is providing an efficient implementation of dynamic function dispatch. This is the core feature, without i
by hasenj 12y ago
I think the key to the success of Java's flavor of OO is providing an efficient implementation of dynamic function dispatch. This is the core feature, without it, OO would be useless.
The same feature can easily be achieved in functional languages (including javascript), but its performance doesn't scale well at all.
This is the case even in javascript: attaching dynamic functions to object instances performs significantly worse than relying on a prototype chain.
When a function is defined in the prototype chain, it's defined once and shared across all instances.
In Java, when you have a reference to an abstract class, and you call `object.method(args..)`, you don't know which function is being called. It's somewhat like if you have a function pointer/reference and called `method(object, args...)`.
Java lets you do this without losing all the benefits of static type checking.