expression templates

bearophile bearophileHUGS at lycos.com
Wed Mar 30 17:48:27 PDT 2011


Regarding expression templates in C++ and D there is something to be considered (this was probably already discussed in past, but probably not by me). D is or hopes to become a language quite fit for numerics processing too. Features like vectors ops, multiple dimensional dollars symbols, array slicing, inline assembly, string mixins, operator overloading, some support for parallelism, etc, and the general low-level nature of its C roots, make it good (or acceptable) for heavy numeric processing on the CPUs (and maybe acceptable on the GPUs too).

C++ template meta-programming looks hard to, but part of the complexity comes from the syntax, weird semantics corner cases, cheap limitations etc. If you translate some C++ template meta-programming code with a functional language, you see how much semantically easy most of that C++ code is. C++ template syntax is a kludge. D templates improve the situation some and remove some wizardry from C++ templates; I have learnt to use D templates in a relatively short time.

Similarly, there's some need for active libraries like Blitz++, that improve performance of the numeric code doing with library code some of the optimizations done by Fortran compilers (Blitz++ performs tiling, reordering, collapsing, unit stride optimizations, etc.). As with template meta-programming, such optimizations are not very complex, but they become wizardry if you have to implement them with C++ templates (and maybe with D templates too).

So is D going to somehow help the implementation of those optimizations, or is this need too much niche to deserve this work?

Bye,
bearophile


More information about the Digitalmars-d mailing list