Advent of Code 2023

Julian Fondren julian.fondren at gmail.com
Mon Dec 4 04:17:10 UTC 2023


On Monday, 4 December 2023 at 03:50:47 UTC, Siarhei Siamashka 
wrote:
> On Monday, 4 December 2023 at 03:07:07 UTC, matheus wrote:
>>> import std.stdio;
>>> import std.algorithm;
>>> import std.array;
>>> import std.format;
>>> import std.conv;
>>> import std.string;
>>> ...
>>
>> Why do you do multiple imports instead of one import std;?
>>
>> I means is there any difference in CT?
>
> The code indeed compiles faster with fewer imports and this 
> pays off in the long run for the actively developed large 
> projects. Additionally, it's a good idea not to pollute the 
> namespace with the functions that the developer has no 
> intention to use.

```
   dmd -betterC hellobc.d ran
     6.18 ± 0.33 times faster than dmd hellosel.d
    19.76 ± 1.06 times faster than dmd hellostd.d
```
26ms, 136ms, 470ms.
16MB, 56MB, 154MB.
-betterC with selected import of core.stdc.stdio
selected import of std.stdio.writeln
import std.

D has the capability to compile extremely quickly. dmd compiles 
itself in a second or two. But it also gives you plenty of 
opportunities to trade that for convenience.


More information about the Digitalmars-d-learn mailing list