It is admitted a large binary, but hello world is not
a simple program: it pulls in the fmt library, which can
print many more interesting things than hello world,
and that in turn pulls in the reflection library, and the
dynamic type support, and the garbage collector,
and so on. It's a non-trivial amount of code. It's not
like printing hello world twice doubles the size of
the binary.
For what it's worth, a completely non-scientific
comparison:
; cat >x.c
#include <stdio.h>
int main(void) {
printf("hello, world\n");
return 0;
}
; gcc -static x.c
; ls -l a.out
-rwxr-x--- 1 rsc eng 665642 Nov 11 00:19 a.out
; size a.out
text data bss dec hex filename
573031 3424 12296 588751 8fbcf a.out
;
; cat >x.go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n");
}
; 6g x.go
; 6l x.6
; ls -l 6.out
-rwxr-x--- 1 rsc eng 634803 Nov 11 00:19 6.out
; size 6.out
text data bss dec hex filename
136145 225832 2180280 2542257 26cab1 6.out
;
Russ
> It is admitted a large binary, but hello world is not
> a simple program: it pulls in the fmt library, which can
> print many more interesting things than hello world,
> and that in turn pulls in the reflection library, and the
> dynamic type support, and the garbage collector,
> and so on. It's a non-trivial amount of code.
Is there a plan to support shared/dynamic libraries? Sounds like that would be a huge help for executable size, which in turn would lower the memory footprint when running multiple Go processes.
—Jens