Skip to main content

Just When You Thought Your Little Language Was Safe: “Expression Templates” in Java

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2177))

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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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.

    Google Scholar 

  2. Berlin, A., and Weise, D. Compiling scientific code using partial evaluation. Computer23, 12 (Dec 1990),25–37.

    Google Scholar 

  3. 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.

    Google Scholar 

  4. 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.

    Google Scholar 

  5. 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.

    Google Scholar 

  6. Interim Java Grande report. Tech. Rep.JGF-TR-4, Java Grande Committee, 1999.

    Google Scholar 

  7. Jones, N. D. An introduction to partial evaluation. ACM Computing Surveys28, 3 (Sept. 1996),480–503

    Article  Google Scholar 

  8. 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.

    Google Scholar 

  9. 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

    Google Scholar 

  10. Kleinrubatscher, P., Kriegshaber, A., Zöchling, R., and Glück, R. Fortran program specialization. SIGPLAN Notices30, 4 (1995), 61–70.

    Article  Google Scholar 

  11. 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

    Google Scholar 

  12. 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

    Google Scholar 

  13. Sarkar, V., and Knobe, K. Enabling sparse constant propagation of array elements via array SSA form. Lecture Notes in Computer Science1503 (1998),33.

    Google Scholar 

  14. 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.

    Article  Google Scholar 

  15. Taha, W., and Sheard, T. Multi-stage programming with explicit annotations. ACM SIGPLAN Notices32, 12 (1997), 203–217.

    Article  Google Scholar 

  16. Veldhuizen, T. L. Expression templates. C++ Report7, 5 (June 1995), 26–31. Reprinted in C++ Gems, ed.Stanley Lippman.

    Google Scholar 

  17. 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.

    Google Scholar 

  18. 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.

    Google Scholar 

  19. 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.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics