compiled code file size

Dicebot public at dicebot.lv
Fri Sep 20 09:49:51 PDT 2013


On Friday, 20 September 2013 at 16:20:34 UTC, Duke Normandin 
wrote:
> I'm re-visiting the D language. I've compared the file sizes of 
> 2 executables - 1 is compiled C code using gcc; the other is D 
> code using dmd.
>
> helloWorld.d => helloWorld.exe = 146,972 bytes
> ex1hello.c => ex1-hello.exe = 5,661 bytes
>
> Why such a huge difference???
>
> Duke

You are doing it wrong.
```
$ gcc hello.c; ls -lah a.out
-rwxr-xr-x 1 dicebot users 4.9K Sep 20 18:47 a.out
```
vs
```
$ gcc -static hello.c; ls -lah a.out
-rwxr-xr-x 1 dicebot users 717K Sep 20 18:48 a.out
```

(C standard library is dynamically linked by default)

So actual relative difference is about 2x - quite big but not as 
huge. It mostly comes from additional D runtime stuff.


More information about the Digitalmars-d mailing list