D Editions
Steven Schveighoffer
schveiguy at gmail.com
Mon Jun 3 02:36:08 UTC 2024
On Monday, 3 June 2024 at 00:57:45 UTC, Adam Wilson wrote:
> On Sunday, 2 June 2024 at 09:38:54 UTC, Dukc wrote:
>> Yes, I agree this is something we need to decide. I also agree
>> that locking DRuntime API isn't a good idea.
>>
>> But, I think it should be updated with the compiler, not with
>> Phobos. DRuntime is essentially language API that is called
>> without special langauge syntax.
>
> I'm writing a longer post on this subject. But the TL;DR is
> that this view is factually incorrect and is based on an
> misunderstanding of what DRT is to the ecosystem. Only a tiny
> fraction of DRT today deals with the compiler (as an API for
> language). The vast majority of DRT is providing system
> resources to Phobos. Given that the library-system interface is
> only going to continue to grow, logic would dictate that tying
> DRT to the library is the only practical choice. Tying DRT to
> the compiler forces Phobos to wait for the latest edition to
> use the latest DRT, which makes no sense given that the vast
> majority of the work is on the system-interface components and
> not the compiler-interface.
This is not correct. DRT is the library side of the compiler
implementation. It does not exist mostly to support phobos.
It supplies the implementation of:
* AAs
* Garbage Collector
* Threads and threading primitives (needed for garbage collector
support)
* static constructors/destructors
* TypeInfo and Object
* string switch
* interpolation expression sequences
* varargs
* exceptions and stack unwinding
These are *very much* tied to the compiler, and do not belong in
phobos.
Incidentally, it has some pieces that are not compiler hooks or
language specific pieces, but are useful to implement the
druntime parts, and so they go into druntime because of the
dependency direction.
It also contains system library bindings, which aren't part of
the language, but are useful in both druntime and phobos.
> Fun historical note, DRT began as a system-interface library
> for Tango and only later was it used as a convenient place to
> put compiler hooks. The commonly held view that DRT primarily
> exists to serve the compiler is a fascinating confirmation that
> we've moved past the Tango/Phobos split though.
Tango's language runtime began as "Ares", an alternate to phobos,
and was incorporated into Tango.
At the time Druntime was split out from Tango, both Tango and
Phobos had the language runtime completely contained within their
codebases, but the runtimes were incompatible. Druntime was an
effort to separate and release a common runtime so both Tango and
Phobos libraries could work together. Unfortunately, that
possibility never came to fruition as druntime was D2 only, and
Tango did not make the move to D2 until much much later (and by
then, not many were using it).
So in fact, DRuntime is *exactly* an effort to serve just the
compiler-needed library hooks as narrowly as possible.
Druntime needs to continue to exist as the library implementation
of the language. I think it serves a very well-defined separation
point, and we should not abandon that. When porting to a new
platform, one only needs to port druntime (not a small task), not
phobos.
-Steve
More information about the dip.ideas
mailing list