Filesize of D binaries?
Anders F Björklund
afb at algonet.se
Sat Jan 6 05:37:24 PST 2007
Mike Simons wrote:
> Someone recently pointed out to me that a simple hello world sample that only
> imports std.stdio and prints a single line to console compiles to a rather
> hefty 250k! The program was 7 lines long! The compiled C equivalent is 7k.
250K sounds a bit much, like if debugging symbols wasn't stripped ?
> I'm using gdc on linux.
> Is there something I'm missing (i.e. is the compiler chucking in stuff I don't
> need?) or is this for real?
> Is it just an issue with immature compilers?
Phobos is statically linked, libstdc++ is usually dynamically linked.
On platforms where C++ is static, like Mac OS X 10.3, it's more even:
31 hello.sh (#!/bin/sh)
637 hello.jar (Java)
12K hello_c (C)
156K hello_d (D)
368K hello_cpp (C++)
It's usually not a problem, unless you are *really* cramped for space.
An advantage is that you avoid the libstdc++ version portability hell.
i.e. you can just run the program, without extra runtime dependencies.
--anders
PS. The Java version is smallest or largest, depending on
whether you include the size of the JVM runtime or not...
(If you compile to an EXE using GCJ, it's more like 10M!)
Of course, it also took longest to run (with JVM startup)
More information about the Digitalmars-d
mailing list