Why C++ compiles slowly

Walter Bright newshound2 at digitalmars.com
Thu Aug 19 11:00:00 PDT 2010


Leandro Lucarella wrote:
> I think in D you can do the same level of incremental compilation as in
> C/C++ but is not as natural. For one, in D is not natural to separate
> declarations from definitions, so a file in D tends to be dependent in
> *many* *many* other files because of excessive imports, so even when you
> can do separate compilation, unless you are *extremely* careful (much
> more than in C/C++ I think) you'll end up having to recompile the whole
> project even you change just one file because of the dependency madness.

That's why dmd can *automatically* generate .di files. But still, even writing 
.di files by hand cannot be any harder than writing a C++ .h file.


> I know you can do separate compilation as in C/C++ writing the
> declarations in a different file, or generating/using .di files, but
> also you'll probably end up using libraries that don't do that (as
> somebody mentioned for C++ + STL) and end up in a dependency madness
> anyway. It's just not natural to do so in D, it even encourages not
> doing it as one of the main advertised features is you don't have to
> separate declarations from definitions.
> 
> And I'm not saying that is an easy to solve problem, I'm just saying
> that I agree D doesn't scale well in terms of incremental compilations
> for big projects, unless you go against D natural way on doing things.

In no case is it worse than C++, and as soon as you import a file more than once 
you're faster.


More information about the Digitalmars-d mailing list