Why using wrappers for D?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 3 11:25:06 PDT 2016


On Monday, October 03, 2016 18:05:47 Chalix via Digitalmars-d-learn wrote:
> Ah great, now I understand it :)
> I thought, import and include would work the same way (taking all
> the code in the .h or .d file and pasting it into the other file).
> But if import extracts only the definitions, it is clear, that
> you have to link against the library, or to add all the .d files
> to your source code.

#include is a _very_ inefficient way to do things. It results in the same
code being compiled over and over again, which is why pretty much every
language post C/C++ has some sort of symbol import mechanism in attempt to
compile everything only once. The way it works in D, you do end up with some
amount of work being redone if you do incremental compilation, but even
then, it minimizes how much it has to redo, and there are future
improvements planned which will make it even better. There's a reason why D
compiles so much faster than C/C++. :)

You should probably read this article by Walter on why C/C++ compilation is
so slow:

http://www.digitalmars.com/articles/b54.html

It's quite enlightening - and horrifying.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list