Modern C++ Lamentations

Ivan Kazmenko gassa at
Sun Dec 30 00:18:23 UTC 2018

On Saturday, 29 December 2018 at 15:34:19 UTC, H. S. Teoh wrote:
> 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.

I thought I'd chime in with a similar experience.  I have this 
small library, testlib.d, used to check text outputs for 
programming contest problems (used internally, no public 
repository right now).  As one can imagine, a regular expression 
is sometimes handy to parse simple alphanumeric constructs and 
check their format.  But after using std.regex a bit, I put the 
import down into one function and templated it, and mostly 
stopped using the function in new checkers' code, developing some 
not-so-nice workarounds instead.  A typical checker is very 
short, a couple dozen to a couple hundred lines, and this change 
brings compile times from 5+ seconds to 2+ seconds.

Sorry, I just can't stand having to wait 5+ seconds to compile a 
50-liner, repeatedly, when the development time for a single 
checker is on the scale of minutes, not hours.  The C++ analog 
library ( is currently 
4500+ lines long, and so also takes 5+ seconds to compile a 
trivial checker.  This was actually one of the incentives for me 
to switch to D with a homebrew library for writing checkers.

I know there was a move to make Phobos compilation faster a few 
months ago, and things seemed to improve a little then, but 
std.regex still adds seconds of compilation time.

Ivan Kazmenko.

More information about the Digitalmars-d mailing list