Since October I have been using an experimental feature I created for the diet-ng package [1] that allows one to alter just the HTML portions of a diet template and have the server re-render those pages. It has saved me significant development time as I can e.g. alter a class on an html element, add javascript, just about anything that doesn't have to do with running actual D code, and I do not need to rebuild my entire application. Those of you who watched my dconf 2018 presentation may have heard me talk about the issue of vibe.d build times.

Today, Sönke merged and released my experimental feature called "Live Mode" into diet-ng, so it is now available for everyone to play with under version 1.7.0 of diet-ng. Go check out the README, and please let me know if you find any issues with it. Note it definitely is still experimental, and doesn't support everything you can do in a diet template (see the README for details).

In order to do this, I had to make all the code that diet-ng runs using templates runnable at runtime. In addition, because vibe.d generally wants everything @safe, diet-ng should now be fully @safe.

In addition to this, I have also been using the DietUseCache feature of diet-ng, another experimental feature, which allows to skip the entire compilation step of diet templates, and just import a cached version of the compiled file (again see README of diet-ng for details). However, this has a significant limitation -- you need to build the template once without caching so it can be put out as a cached file during the first run of the application. As I was running up against memory limitations on my system for running this CTFE, and the Live mode forced me to make everything doable at runtime, I decided to build a "pre-compiler" for the templates, that builds the cache files before the compilation step. In my project, this lowered my build time from 38 seconds down to 11, and the caching saves about 25% of the compiler memory consumption.

This utility I called dietpc I'm very happy to say is now available as a dub package for your usage [2]. Please file any bugs for it there or on the diet-ng package as appropriate, and I will work on making sure everything works as expected.

Thank you to Sönke for accepting this feature and the whole vibe.d team for these great projects!

-Steve

[1] https://code.dlang.org/packages/diet-ng
[2] https://code.dlang.org/packages/dietpc

Reply via email to