Imagine each binary being 5 mb on average and multiply that by 100.
Imagine each binary being 5 mb on average and multiply that by 100.
Are you sure it's because they are statically compiled?
Not because each binary has DWARF debug symbols in it so that there are useful stack traces?
> Imagine each binary being 5 mb on average and multiply that by 100.
I don't think it's a factor of 100 times, that seems a bit outrageous.
> I don't think it's a factor of 100 times, that seems a bit outrageous.
I think he means 100 utilities all weighing in at 5mb
Removing DWARF information with -ldflags -w reduces the size of the binary by 20%. The binary is 1.8MB originally...
$ go build hello.go
$ wc -c hello
1806192 hello
$ go build -ldflags -w hello.go
$ wc -c hello
1408880 hello
the rest is pretty much all runtime, the hello world itself should take about 10k, that's more or less the size of the C or dynamically linked Rust versions (Rust also uses static linking by default, and the hello world is 300k in that case) $ cat > t.go
package main
func main() {}
$ go build t.go
$ wc -c t
623280 t
$ nm t | wc -l
1029
$ cat > t.go
package main
import "fmt"
func main() { fmt.Println("hello world") }
$ go build t.go
$ nm t | wc -l
2541Shared libraries for the std lib would definitely be nice for utils, but they do have drawbacks too (dll-hell).
If you are severely resource constrained, and need to have lots of tiny programs resident in memory at once, then go with static linking is not a good choice, but does this preclude using go tools on modern servers, desktops, phones where many binaries are typically > 1MB today and many are only run for short periods anyway?
There is also .a/.lib hell, the only difference is when it gets handled.
In Windows dll-hell is a solved problem since Windows 2000 for any developer that bothers to follow Microsoft guidelines instead of copying dlls into systems directories.