Just When You Thought Your Little Language Was Safe: ``Expression Templates'' in Java

  • Authors:
  • Todd L. Veldhuizen

  • Affiliations:
  • -

  • Venue:
  • GCSE '00 Proceedings of the Second International Symposium on Generative and Component-Based Software Engineering-Revised Papers
  • Year:
  • 2000

Quantified Score

Hi-index 0.00

Visualization

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 complexities such as 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 [12,18]. 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.