D is our last hope

Walter Bright newshound2 at digitalmars.com
Thu Dec 21 23:04:30 UTC 2023


On 12/21/2023 7:13 AM, Siarhei Siamashka wrote:
> Its main selling point is the 
> compilation speed. However the out-of-the-box performance of `rdmd helloworld.d` 
> is very far from perfect and looks inferior compared to `go run helloworld.go`. 

It's a good point. One of the likely suspects is object.d. It started out as a 
small, single file. But it has bloated up to biblical proportions, which have to 
be compiled by every separately compiled D module. (If all the modules to a 
project are presented on the same command line, object.d only gets compiled 
once, and that effort is amortized over the other modules.)

For example, object.d has unit tests in it. Unit tests are a great feature of D, 
but there they are in the wrong place. object.d should be split into object.d 
and object.di. The unit tests and definitions go in object.d, the declarations 
go in object.di.

Another culprit is writefln(). For all its faults, printf() is compact, fast, 
does not allocate memory, and:

```
extern (C) pragma(printf) int printf(const(char)* format, ...);
```

If anyone wants to pick up the flag on this,
https://issues.dlang.org/show_bug.cgi?id=24296

is all the compiler needs to see to use it. writefln() is anything but. We can 
do better.

Another problem is nobody ever profiles dmd anymore. There are no instructions 
in build.d in how to run the profiler.


More information about the Digitalmars-d mailing list