Article first draft: CTFE,DDL,DLL all dead ?

Burton Radons burton-radons at shaw.ca
Mon Feb 18 11:44:00 PST 2008


Don Clugston Wrote:

> Burton Radons wrote:
> > Bjoern Wrote:
> > 
> >> I will read your article a third time, but I think it means : No need 
> >> for CTFE anymore, DDL is dead. Furthermore we can use D as ultra fast 
> >> scripting on-the-fly-compiled language. (using eval)
> >>
> >> Sorry I must be wrong!
> > 
> > It can take a big chunk out of any situation where you need to use a switch to select between templates, but it'll have little effect on anything which uses templating and CTFE for expressiveness. Or maybe it will - it's a diverse concept that I haven't fully explored.
> 
> The back-end of my BLADE code uses CTFE to generates asm for floating point 
> array operations at compile-time; but the same CTFE can be used without 
> modification for code generation at run-time. The advantage at run-time (or at 
> least, at install time) is that you know the CPU, number of cores, and cache size.

This can also work at a slightly higher level, where your object file has multiple versions of a function for different feature sets and the custom linker chooses the ideal one at runtime. Another use would be to make the inliner work better; I've noticed that sometimes it's better to avoid asm statements because they prevent the optimiser from inlining the function and applying further optimisations to it. So you could compile the code with a regular D function, then link whatever doesn't inline the regular function to a custom-written asm function, improving execution speed in both scenarios.

However that won't be helpful if the compiler's only reasoning about inlining is the number of statements in the function; I haven't really tested this.

> I think that in your article you should include a brief comparison with the JIT 
> techniques of Java/.NET. To a naive reading, it sounds similar; but they are 
> fundamentally different. .NET's last-minute conversion of intermediate form to 
> native code doesn't buy you very much. JIT source code generation is something 
> else entirely. Using your library, you can have JIT selection of the 
> _algorithm_. FFTW (www.fftw.org) is an interesting example of this sort of thing.

I don't know much about Sun's Java or Microsoft's .NET JITs; I'll read about them when I have the time.



More information about the Digitalmars-d-announce mailing list