D is supposed to compile fast.

Nicholas Wilson iamthewilsonator at hotmail.com
Fri Nov 23 10:00:17 UTC 2018


On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote:
> Any time I see people mention the benefits of D, I see "compile 
> times" "compile times" "compile times" over and over.
>
> I'm using very modest amounts of templates, for a fairly small 
> sized program (very early work toward a game), and I'm hitting 
> ~15 seconds compile time in LDC and ~7 seconds in DMD. And I'm 
> not even compiling with optimizations!

Templates are slow, slower than CTFE.

> ldc2 -w -ofextra  extra.d molto.d helper.d editor.d common.d 
> map.d object_t.d animation.d ini.d  -L-L. $@    -gc -d-debug=3  
> -de -fdmd-trace-functions
>
> dmd -w -ofextra extra.d molto.d helper.d editor.d common.d 
> map.d object_t.d animation.d ini.d -profile=gc  -profile  -g 
> -debug -color -L-L.
>
> I keep putting stuff into new files, but it feels like it's 
> compiling everything from scratch / not getting faster the way 
> C++ does.

If you pass all the files on the command line then they all get 
(re)compiled.
Have separate rules for each file, although if you are using 
template from each file in every file that may not help a whole 
lot.

> And I'm not even bringing up the 800MB of RAM required because 
> I dared to import std.regex. (On a laptop with 2 GB of RAM. 
> RIP. If I dare to have tabs open, the compile time goes into 
> the minutes thanks to swapping.)

Yep, on the upside the regexen are very fast at runtime. 
std.regex depending on how much of it you are using could also be 
a cause of your problem.you might want to take a look at 
https://blog.thecybershadow.net/2018/02/07/dmdprof/
https://github.com/CyberShadow/dmdprof to see whats taking so long

Is this code online? Its a bit difficult to give specific advice 
without it.


More information about the Digitalmars-d-learn mailing list