Dynamically Typed Languages and
the invokedynamic Instruction
RAYMOND GALLARDO
The new invokedynamic instruction enables a runtime system to customize the linkage between a call site and
a method implementation, instead of using hardwired linkage behavior.
JAVA IN ACTION
PHOTOGRAPH BY
GENEVIÈVE ARBOIT
When Sun was developing the Java platform, it did
not encourage developers to run
other programming languages
on the Java virtual machine
(JVM). As a matter of fact, Sun
wanted developers to use Java
as the foremost programming
language for enterprise development. Ten years later, close
to the release of Java Platform,
Standard Edition 7 (Java SE 7),
this goal has been accomplished.
Developers recognize the extraordinary value in the Java platform and in the JVM as a deployment vehicle. However, they also
recognize that the Java platform
isn’t always the best tool. New
and old languages, such as Ruby
and Python, have been reimplemented, for example, as JRuby
and JPython, to run on the JVM.
Why have developers bothered
to reimplement these languages
rather than use their original C
counterparts? Developers could
have instead converted their old
code to Java, but implementations
such as JRuby and JPython can
take advantage of the following
unique JVM features:
The Difference Between
Statically and Dynamically
Typed Languages
Java is a statically typed language.
This means it performs type
checking at compile time. Type
checking is the process of verifying that a program is type-safe. A
program is type-safe if the arguments for all its operations are
the correct type.
Ruby and Python are dynamically typed languages. This means
they perform type checking at
runtime. These languages typically do not have any type information available at compile time,
so the type of an object can be
determined only at runtime.
Statically Typed Languages
Are Not Necessarily Strongly
Typed Languages
A programming language that
features strong typing specifies restrictions on the types of
values supplied to its operations.
If a computer language such as
Java implements strong typing, it
prevents the execution of an operation if its arguments have the
wrong type. Conversely, a language that features weak typing
would implicitly convert (or cast)
the arguments of an operation if
those arguments have wrong or
incompatible types.
Statically typed programming
languages can employ strong
typing or weak typing. Similarly,
dynamically typed languages
can also apply strong typing or
weak typing. For example, Ruby
is dynamically typed and strongly
typed. Once a variable has been
initialized with a value of some
type, Ruby will not implicitly
convert the variable into another
ABOUT US
blog