Minimal druntime?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jul 27 17:57:07 UTC 2019


On Saturday, July 27, 2019 8:20:52 AM MDT Ethan via Digitalmars-d wrote:
> On Saturday, 27 July 2019 at 13:11:23 UTC, Jonathan M Davis wrote:
> > It sounds to me like what you want is -betterC.
>
> It's kind of not though.
>
> I don't want a subset of D, I want DMD to not inject things in to
> my library that I just plain won't use.
>
> I'd already considered -betterC, and immediately decided it was
> going to be too much hassle after writing one line and finding
> out the compiler doesn't agree with my coding style. The code is
> going to compile with and without -betterC, which itself is a
> massive undertaking at this point.
>
> I've got a related point about the Unity guys writing High
> Performance C#. If C# is so good, why do you need a subset of it?
> This exact argument is what I have about -betterC. If D is so
> good, why do I need a subset of it?

Personally, I'd pretty much only use -betterC to help port a C/C++ library
or program to D. I sure wouldn't want to use a stripped down version of D
normally. But if you want to avoid stuff like TypeInfo, or you want your
library to just look like it's basically C/C++, then that's the direction
you're going. To fully use D's features, you need druntime with everything
that it does. In theory, druntime could be improved to be more pay-as-you-go
than it is, and work is slowly being done in that area, but what druntime
does really does provide language functionality, and trying to avoid parts
of it basically means avoiding language functionality. It's not like D's
features all come for free.

I actually think that -betterC is mostly a waste of time, because I don't
see enough benefit in using a stripped down version of D over just using C++
to bother, but it definitely can have benefits when porting code, and some
people seem to think that it's the way to go, much as I really don't
understand that.

However, D _is_ a general purpose programming language, and different people
have different constraints that they operate under. For the vast majority of
programs, what druntime does isn't a big deal at all. Complaints over stuff
like D using a GC are mostly unreasonable. But there are domains where it's
more problematic than is normally the case (games being one of those,
because they typically can't afford the delays from the stop-the-world GC),
and when you're in that kind of environment, you do potentially need to
avoid aspects of D (and would presumably have to do something similar with
C# for similar reasons) - or at least program in a way that tries to work
around some of the downsides rather than just using the language like most
people would (e.g. having a separate thread that the GC has no control over
to deal with real-time stuff or specifically disabling the GC in certain
sections of code). And in general, when having multiple languages interact,
things can get a bit entertaining and potentially require avoiding aspects
of D.

- Jonathan M Davis





More information about the Digitalmars-d mailing list