Found on Medium: Why we chose the D Language and vibe.d

Steven Schveighoffer schveiguy at
Thu Dec 20 14:39:32 UTC 2018

On 12/19/18 5:52 PM, bauss wrote:
> On Wednesday, 19 December 2018 at 17:42:00 UTC, H. S. Teoh wrote:
>> On Wed, Dec 19, 2018 at 10:28:59AM -0500, Steven Schveighoffer via 
>> Digitalmars-d wrote: [...]
>>> I'm curious if the author has any words to say on vibe.d compile 
>>> times. If they value fast compile times over performance, I can't 
>>> imagine they are using diet templates.
>> [...]
>> Yeah, in my own vibe.d project I eventually separated out diet 
>> templates into their own modules that are separated from "business 
>> logic". Which I should be doing anyway, I suppose, in the spirit of 
>> good software design, but the primary motivation at the time was to 
>> keep compilation times under control.
>> I'm quite tempted to cook up my own HTML generation framework that 
>> does codegen as a separate step, using D tools to generate D code, 
>> that then gets compiled into the actual executable. Despite all the 
>> power of CTFE and other compile-time features, past a certain level of 
>> complexity I really want to physically see the generated code rather 
>> than wade through inscrutable templates and mixins and try to imagine 
>> in my head what the generated code looks like. (You wouldn't believe 
>> it, debugging is SO MUCH easier when you don't have to instantiate 
>> templates in your head just to understand what the code is trying to 
>> do, but can just look at the actual generated code being fed to the 
>> compiler as a file.)
>> T
> Pretty much solved in Diamond.
> Basically:
> viewResult.source is the exact generated source for a specific view.

What are the compile-time penalties for diamond templates? I have to try 
it one of these days.

I think diet templates are great, but the compile-time penalty is so 
bad. I really think they would be more palatable if they were processed 
pre-compilation. Parsing and cross-compiling a DSL right in the compiler 
is a neat trick, but there are certainly better ways to do it than with 
mixins and CTFE.


More information about the Digitalmars-d mailing list