3 ms·
I've also compiled small programs that I wrote in D and Free Pascal (not equivalent to the program above, but simple command-line utilities), like wc clones or
by vram22 9y ago
I've also compiled small programs that I wrote in D and Free Pascal (not equivalent to the program above, but simple command-line utilities), like wc clones or similar, and their size is quite a bit smaller than the Go binary size above, e.g. in the range of 50 to 100 KB (IIRC). And similar programs in C were ~22 KB. I know there can be many reasons for the differences, such as what libraries are included by default, maybe transitive dependencies, etc.
- kbenson 9y agoThere's a Rust FAQ entry on file sizes[1], but it also sort of glosses over that Rust defaults to static compilation. Go does as well, and I believe Go does as well. Part of the size of executables can be attributed to these languages implementing their own libc equivalents (or wrapping libc). The stories probably fairly nuanced as each language has it's own story, but that's the general idea. 1: https://www.rust-lang.org/en-US/faq.html#why-do-rust-programs-have-larger-binary-sizes-than-C-programs https://www.rust-lang.org/en-US/faq.html#why-do-rust-program...
- vram22 9y agoThanks. >Part of the size of executables can be attributed to these languages implementing their own libc equivalents (or wrapping libc). Yes, I agree. Both of them have more features and I guess (I know it a bit for Go, not sure for Rust) do some more / higher level things than plain C, which may partly be why they need to wrap libc (or implement the equivalent) with non-trivial additional code.