performance of OO dispatch in inner loops

Brendan Eich brendan at
Fri Mar 21 12:42:56 PDT 2008

On Mar 21, 2008, at 5:32 AM, ToolmakerSteve98 wrote:

> More bad news for dynamic typing as I remember the details more  
> clearly:
> turns out the quentessential activity in the complex control logic  
> we were
> seeing for interactive multimedia, is that one object queries  
> another object
> for one or two properties, does a tiny bit of decision making using  
> that
> info and its own properties, modifies its state a bit, then fires a  
> message
> off elsewhere. Performance was dominated by how fast you could get at
> properties on yourself and on the objects you were cooperating  
> with. The
> better you could pin down ahead of time how to get hold of those  
> properties,
> the better your performance.

This is a valid concern, about the classic OOP folly where lots of  
little methods suffer high dynamic dispatch overhead. But there is at  
least 15 years of research on how to optimize better, going back to  
the Self and Strongtalk [1] work. More recent work we are supporting  
at UC Irvine [2] shows a lot of promise, and it's feeding into  
Tamarin Tracing.

Again, I'm not writing checks I can't yet cash (but we are investing,  
making bets in code under development). On the other hand, IMHO you  
are pessimizing for the two-decade-old trailing edge. It's easy to go  
from "want speed" to "require static types" and bypass the "optimize  
dynamic types enough not to need more speed" state, but taking this  
shortcut risks leaving lots of developers and content behind. It's a  
huge rewrite tax at the limit, unpayable on the web.

What's more, if the static type system is weak, this course may just  
amount to requiring programmers to overspecify their code for the  
sake of VM implementors, without gaining much in the way of safety  
properties or other programming in the large benefits. Such  
overspecification can turn code into "hardware" that is hard to  
evolve quickly, mash up, merge and diverge, reuse at Web scale, etc.

I'm certainly on the edge of over-generalizing here, but I don't  
believe this is just hand-waving. You can see the problem, highly  
relevant to ES4, in the swerve toward classical OOP a la Java 1 that  
AS3 and Flex took targeting the Flash Player. It's not "bad", and for  
some programmers and use cases it works great. On the other hand, the  
community did grumble about "turning the language into Java", did  
over-annotate types without winning too often, and still ended up  
wanting dynamic language features that were underserved or left out.



More information about the Es4-discuss mailing list