D is our last hope

H. S. Teoh hsteoh at qfbox.info
Tue Dec 19 20:49:23 UTC 2023


On Tue, Dec 19, 2023 at 08:07:23PM +0000, FeepingCreature via Digitalmars-d wrote:
[...]
> (seriously, figure out a way to dogfood Phobos, it's insane that the
> premier project in the language refuses to use its stdlib),
[...]

AIUI, this has much more to do with historical baggage than reluctance
to dogfood Phobos. DMD was originally written in C++, and accordingly
written in a way that's idiomatic to C++. Moreover, D has changed quite
a bit over time; modern D today is quite different from the "alternative
C++" that it resembled in its earlier days. A lot of modern idioms
didn't even exist back then.  When the desire to bootstrap D came
around, the DMD codebase was already firmly entrenched in C++ style.
Thanks to the monumental efforts of a few dedicated DMD devs, an
automatic translation scheme was worked out that translated, or to be
more precise *transliterated* the DMD C++ code into D.  If you've done
any kind of similar work before, you'd realize that this kind of process
can at most give you syntactically-correct D code written in C++ style,
a far cry from idiomatic D.  Which is what we have today: DMD is mostly
still written in a C++-like style, with bits and pieces here and there
gradually replaced by more idiomatic D.  But progress is slow -- DMD is
a large, complex codebase, and you can't just rewrite it overnight.

Moreover, DMD has a long history of being fine-tuned for maximum
performance. This kind of optimization cannot simply be translated
overnight into idiomatic D without performance consequences. It does not
mean that idiomatic D is not performant; what it means is that if you're
going to rewrite a piece of C++-style optimized code in idiomatic D,
you're gonna have to repeat those decades of fine-tuning and tweaking on
the new Phobos-style code before you'll get on par with current
performance.  It isn't as if there's a magic switch you flip to change
all C++-style array/list code into Phobos ranges and you'll magically
get on-par performance right out of the box. It takes time and effort to
go through the code and reengineer it in the new idiom. There are
different tradeoffs that you need to make decisions on, due to the
different idioms employed.  And obviously, being one of the big selling
points of D, fast compilation isn't something we can compromise on, even
temporarily, so any such effort can't be done piecemeal, you either have
to do it completely, or not do it at all.  But there's little incentive
to pour in the time and effort to achieve the same performance just so
we can pat ourselves on the back that yes, we did it with Phobos-using
code, when the current codebase already has the performance we want.
There are far too many higher-priority things to take care of than this
kind of self-congratulary time and energy sink.

(Caveat: I don't speak for the dmd devs, I'm just a bystander who's fed
up of people assuming and asserting things that aren't necessarily true,
even from my casual POV. So take this with an appropriately-sized grain
of salt.)


T

-- 
They say that "guns don't kill people, people kill people." Well I think the gun helps. If you just stood there and yelled BANG, I don't think you'd kill too many people. -- Eddie Izzard, Dressed to Kill


More information about the Digitalmars-d mailing list