Shriramana Sharma:

However I am somewhat taken aback to see the file size -- 335KiB for a simple Hello World? The equivalent C/C++ programs compiled with Clang
without any -O options produce binaries of less than 10K!

On Windows32 DMD produces binaries for small programs that are often half the size of binaries generated by similar small C++ programs compiled with G++ (about 300+ against 700+).

D has a garbage collector, runtime type introspection (module info, type info, etc), run-time built-in operations on dynamic arrays (concat, append), associative arrays and some of their operations, a sort (but probably the built-in sort and reverse will be deprecated and later removed), exceptions, and more. All that needs space that's absent in the C++ binary.

-------------------

Regan Heath:

The D standard library is currently statically linked. This will change shortly/eventually.

And then you will need the GC somewhere to run it :-) Both static and dynamic linking have their advantages and disadvantages. I think Go has a storng preference for static linking.

Bye,
bearophile

Reply via email to