[PRL] Bob Harper's new blog

will at ccs.neu.edu will at ccs.neu.edu
Thu Mar 17 11:44:46 EDT 2011


Matthias Felleisen wrote:
> How does the dynamic dispatch of inheritance differ from
> the 'random' jumps induced by calls to first-class functions
> in FPLs?

It's a matter of degree.  The ideology of higher-order functions
is not as harmful as the ideology of inheritance.

In most programs that are written in mostly-functional languages,
well over 90% of the procedure calls are made to functions whose
code could be determined at compile time.  Currently available
compilers do a pretty good job of determining those targets,
replacing indirect jumps by direct branches.

In most programs that are written in current object-oriented
languages such as Java and C#, most method calls involve dynamic
dispatch at run time.  There are several reasons for this:

    In current OO languages, loops are expressed without using calls.

    The OO culture continues to emphasize inheritance, which has the
    effect of deprecating static, final, and private methods that
    can't be overridden in a subclass.

    Most of the currently available OO compilers don't even try to
    determine the target of a dynamic method call, mainly because
    the mere possibility of inheritance usually defeats that kind
    of optimization.

Will



More information about the PRL mailing list