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 [14, 20]. 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.
展开▼
机译:C ++中的模板技术允许进行适度的生成式编程:针对特殊问题创建专用代码。模板的使用一直存在争议。确实,迁移到Java的经常被引用的原因之一是,它提供了一种更简单的语言,而没有诸如模板之类的复杂性。 C ++中的生成编程的本质不是模板-语言功能-而是编译器中的基础算法(模板实例化),该算法无意间类似于称为部分评估的优化[14,20]。通过为Java设计局部评估程序,我们在不扩展Java语言的情况下,再现了C ++模板的某些生成编程方面。名为Lunar的原型编译器能够在Java中执行“表达式模板”,以优化数值数组对象。
展开▼