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,wit hout extending the Java language. The prototype compiler,called Lunar,is capable of doing “expression templates” in Java to optimize numerical array objects.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Bassetti, F., Davis, K., and Quinlan, D. Optimizing transformations of stencil operations for parallel object-oriented scientific frameworks on cache-based architectures. Lecture Notes in Computer Science1505 (1998),107.
Berlin, A., and Weise, D. Compiling scientific code using partial evaluation. Computer23, 12 (Dec 1990),25–37.
Consel, C. Binding time analysis for higher order untyped functional languages. In 1990 ACM Conference on Lisp and Functional Programming (June 1990),ACM, ACM Press, pp. 264–272.
Dean, J., Chambers, C., and Grove, D. Selective specialization for objectoriented languages. In Proceedings of the ACM SIGPLAN’95 Conference on Programming Language Design and Implementation (PLDI) (La Jolla,California, 18-21 June 1995),pp. 93–102.
Glück, R., Nakashige, R., and Zöchling, R. Binding-time analysis applied to mathematical algorithms. In System Modelling and Optimization (1995),J. Doležal and J. Fidler, Eds., Chapman & Hall, pp. 137–146.
Interim Java Grande report. Tech. Rep.JGF-TR-4, Java Grande Committee, 1999.
Jones, N. D. An introduction to partial evaluation. ACM Computing Surveys28, 3 (Sept. 1996),480–503
Karmesin, S., Crotinger, J., Cummings, J., Haney, S., Humphrey, W., Reynders, J., Smith, S., and Williams, T. Array design and expression evaluation in POOMA II. In ISCOPE’98 (1998), vol. 1505, Springer-Verlag. Lecture Notes in Computer Science.
Khoo, S. C., and Sundaresh, R. S. Compiling inheritance using partial evaluation. In Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation (New Haven, CN, June 1991), vol. 26(9), pp. 211–222
Kleinrubatscher, P., Kriegshaber, A., Zöchling, R., and Glück, R. Fortran program specialization. SIGPLAN Notices30, 4 (1995), 61–70.
Moreira, J. E., Midkiff, S. P., Gupta, M., Artigas, P. V., Snir, M., and Lawrence, R. D. Java programming for high-performance numerical computing. IBM Systems Journal 39, 1 (2000), 21–56
Salomon, D. J. Using partial evaluation in support of portability,reu sability,an d maintainability. In Compiler Construction’ 96 (Linköping, Sweden, 24-26 Apr. 1996),p p. 208–222
Sarkar, V., and Knobe, K. Enabling sparse constant propagation of array elements via array SSA form. Lecture Notes in Computer Science1503 (1998),33.
Steensgaard, B. Sparse functional stores for imperative programs. In ACM SIGPLAN Workshop on Intermediate Representations (IR’95) (Jan. 1995), vol. 30(3) of SIGPLAN Notices, ACM Press, pp. 62–70.
Taha, W., and Sheard, T. Multi-stage programming with explicit annotations. ACM SIGPLAN Notices32, 12 (1997), 203–217.
Veldhuizen, T. L. Expression templates. C++ Report7, 5 (June 1995), 26–31. Reprinted in C++ Gems, ed.Stanley Lippman.
Veldhuizen, T. L. Arrays in Blitz++. In Proceedings of the 2nd International Scientific Computing in Object-Oriented Parallel Environments (ISCOPE’98) (1998), Lecture Notes in Computer Science,Springer-Verlag.
Veldhuizen, T. L. C++ templates as partial evaluation. In Proceedings of PEPM’99, The ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, ed.O. Danvy, San Antonio, January 1999. (Jan. 1999), University of Aarhus, Dept. of Computer Science, pp. 13–18.
Volanschi, E.-N., Consel, C., Muller, G., and Cowan, C. Declarative specialization of object-oriented programs. In ACM SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’97) (October 1997),pp. 286–300.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Veldhuizen, T.L. (2001). Just When You Thought Your Little Language Was Safe: “Expression Templates” in Java. In: Butler, G., Jarzabek, S. (eds) Generative and Component-Based Software Engineering. GCSE 2000. Lecture Notes in Computer Science, vol 2177. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44815-2_14
Download citation
DOI: https://doi.org/10.1007/3-540-44815-2_14
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42578-6
Online ISBN: 978-3-540-44815-0
eBook Packages: Springer Book Archive