Minimal druntime?
Mike Franklin
slavo5150 at yahoo.com
Mon Jul 29 00:30:03 UTC 2019
On Saturday, 27 July 2019 at 14:20:52 UTC, Ethan wrote:
> 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?
I generally agree and have facetiously referred to betterC as
worseD.
betterC is a janky feature added to the compiler because it was
too much work to modify the compiler and runtime properly. You
can achieve almost the same think by importing druntime, but not
link to it; with a few caveats, that's all betterC does.
Consider the following minimal D program:
--- main.d
void main() { }
Compile with `dmd -release main.d` and you get this:
$ size main
text data bss dec hex filename
526835 53168 2672 582675 8e413 main
Compare that with an equivalent C program:
$ size main
text data bss dec hex filename
1274 512 8 1794 702 main
Whatever D is adding to the binary is probably unnecessary. In
fact, if you modify the above main.d program as...
--- main.d
extern(C) void _d_dso_registry() {}
extern(C) void main() { }
... and then compile and link separate, you get a much more
reasonable result:
$ dmd -release -c main.d
$ gcc test.o -o main
$ size main
text data bss dec hex filename
1430 544 16 1990 7c6 main
Seems to be a lot of room for improvement to achieve a
pay-as-you-go experience.
There are some of us working to improve the compiler-runtime
interface so, hopefully someday, you'll just be able to opt-in to
any feature of the language by simply choosing to use it or not.
I welcome others to join in and help.
Mike
More information about the Digitalmars-d
mailing list