samskivert: Compiling Structural Types on the JVM – Dubochet and Odersky

21 August 2010

Aside from describing how Scala structural types are implemented (via reflection), this paper shows that such an approach isn’t wildly slower than an approach that generates shim classes on the fly. Certainly it’s not ideal for the programmer to have to remember that some kinds of method calls are three times slower than others, but the shim class approach is not without drawbacks either. In addition to the problem of the type of this, it has performance related problems as well, as discussed by Charles Nutter of JRuby fame.

Two interesting developments may change the landscape here: interface injection, which would solve the problem outright, but has low odds of ever seeing the light of day in a shipping JVM, and invokedynamic which could make a reflection-like approach more performant, and should ship with Java 7 (assuming Java 7 ever ships).

Source: ACM PDF

©1999–2022 Michael Bayne