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 [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的部分评估器,我们重现了C ++模板的一些生成编程方面,而无需扩展Java语言。称为Lunar的原型编译器能够在Java中执行“表达式模板”以优化数字数组对象。
展开▼