Research

Technical Report Results

Technical Report TR539:
Just When You Thought your Little Language was Safe: ``Expression Templates'' in Java

Todd L. Veldhuizen
(Jul 2000), 12 pages
Abstract:
Template techniques in C++ allow a modest degree of generative programming: creating specialized code for specialized problems. This use of templates has been controversial; indeed, one of the oft-cited reasons for migrating to Java is that it provides a simpler language, free of the complexities of templates.

The essence of generative programming in C++ is not templates -- the language feature -- but rather the underlying algorithms in the compiler (template instantiation) which unintentionally resemble an optimization called partial evaluation. By devising a partial evaluator for Java, we reproduce some of the generative programming aspects of C++ templates, without extending the Java language. The prototype compiler, called Lunar, is capable of doing ``expression templates'' in Java to optimize numerical array objects.

Available as: