Building C++ modules

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Aug 16 14:57:08 UTC 2019


On Fri, Aug 16, 2019 at 02:05:54PM +0000, Exil via Digitalmars-d wrote:
> On Thursday, 15 August 2019 at 22:37:16 UTC, H. S. Teoh wrote:
> > On Thu, Aug 15, 2019 at 08:09:33PM +0000, Exil via Digitalmars-d wrote:
[...]
> > > D really isn't a fast language, or rather the only frontend is
> > > really really slow especially for CTFE.
> > 
> > I understand the sentiment, but I think it's an unfair comparison.
> > If I were to implement in C++ the equivalent of the some CTFE
> > functionality that's making my compilation slow, I'm almost certain
> > the resulting C++ compile times will make dmd look like lightning
> > speed by comparison.  CTFE *is* known to be slow, no question about
> > that, but I suspect it's still a lot faster than what it would have
> > taken to accomplish the same thing in C++.
> 
> Its a C++ project I converted, and it actually compiled faster in C++.

That's curious.  Is there any code you could share that demonstrates
this?  I'm wondering if your implementation choices could be suboptimal
as far as compile times are concerned.  But it's possible that CTFE is
just that slow. :-/  (So much for that fast-fast-fast slogan. It's been
making me cringe ever since it was introduced, and nobody else seems to
think it's a problem. *shrug*)


> I was using my own program to do what I am doing on CTFE now. As a
> result I was able to optimize it myself.
[...]

Hold on, if you were using an external program to do what you're doing
in CTFE now, that would explain the speed difference.  CTFE is currently
an interpreter, and not a very good one at that (in terms of speed).

In my own D projects, I have no qualms about writing utility programs
that generate D code that then gets compiled as part of the target
executable.  In fact, some of the generated code I have involves pretty
heavy-duty data processing from external data files. Running it in
CTFE would be several orders of magnitude slower than just writing a
code generator utility.  If compile times are important to you, I'd
recommend taking this approach instead.


T

-- 
If lightning were to ever strike an orchestra, it'd always hit the conductor first.


More information about the Digitalmars-d mailing list