Modern C++ Lamentations

H. S. Teoh hsteoh at
Sat Dec 29 15:34:19 UTC 2018

On Sat, Dec 29, 2018 at 10:35:05AM +0000, JN via Digitalmars-d wrote:
> On Saturday, 29 December 2018 at 09:29:30 UTC, Walter Bright wrote:
> >
> > 
> > Time to show off your leet D skilz and see how good we can do it in
> > D!
> I don't know if D is a role model here, considering just importing
> std.regex adds three seconds to compile time -
> .

Yeah no kidding, recently I rewrote a whole bunch of code to get *rid*
of dependency on std.regex because it was too slow, and project
compilation time improved from about 7+ seconds to 2+ seconds.

Let me say that again.  Removing dependency on std.regex (by writing
equivalent functionality by hand) improved compilation times from more
than SEVEN seconds to just over TWO seconds. That's almost TRIPLE the
compilation speed.  The mere act of using std.regex causes compilation
times to TRIPLE.

Let that sink in for a moment.

These days, it has been really hard for me to boast about D compilation
times with a straight face.  True, if you write C-style D code, then
compilation *is* lightning fast.  But modern D has moved away from that
style, and the kind of style that modern D code takes on these days is
template- and CTFE-heavy, both areas of which are in the "extremely
slow" category of D compilation.

This seriously needs to improve if we're going to continue boasting
about compilation times, because otherwise it's becoming more and more
like false advertisement when we talk about D being fast to compile.
I've been saying this ever since we adopted that cringe-worthy
fast-fast-fast slogan on, and it seems not much has improved
since then. These days I'm almost ashamed to talk about D compilation
times. :-/

And don't get me started on dmd's ridiculous memory usage requirements,
which makes it basically unusable on low-memory systems. There is not
even an option to trade off compilation speed for less memory usage.
We're paying mandatory memory tax yet we're still unable to improve
compilation speed of std.regex to within acceptable limits. And modern
C++ compilers have improved enough that on said low-memory systems,
compiling C++ can be actually *faster* than D because g++ stays within
available RAM and therefore isn't thrashing on swap, whereas dmd
thrashes on swap like crazy because it's such a memory hog. And that's
if dmd even finishes compiling at all, before it gets hit by the OOM
killer, otherwise we're looking at finite compilation time vs. infinite
compilation time (because it never finishes).

Don't get me wrong, I still love D for having the best power to ease of
writing ratio, and I can't see myself going back to C++ in the
foreseeable future (or ever again). But we seriously need to improve on
these two areas before we start proclaiming how good D compilation times
are, because that's no longer true.


A bend in the road is not the end of the road unless you fail to make the turn. -- Brian White

More information about the Digitalmars-d mailing list