this is not a new discussion, it started in november 2009. the fact
that it's just coming to 9fans is a sign of how far behind the times
we are :(

the go runtime is ~380k. that one you must carry always even in an
empty program (see below). what you're complaining about is the
side-effect of importing fmt and other big packages such as os and
net. with fmt you're sucking in all the unicode code tables and the
reflection code used to process printing arguments (which you can't
prove will not be used). the initial jump is big, but as your code
grows the binary size tends to increase slower -- all of the imports
are already in. the biggest program from the Go distribution
frequently in use is "godoc". it deals with xml, json, binary
encoding, directory navigation, document preparation, source code
parsing, compression/decompression and serves the major website for go
-- golang.org... that program, statically linked, is 8 megs (64-bit).
i've seen things that deal with graphics which get to 20 megs. that is
reasonable, i think.

here's an illustrative progression of go binary sizes:

$ cat > t.go
package main
func main(){
}
$ go build t.go; ls -l t
-rwxr-xr-x  1 andrey  wheel  384880 Mar 23 12:43 t
$ cat > t.go
package main
func main(){
    println("hello")
}
$ go build t.go; ls -l t; ./t
-rwxr-xr-x  1 andrey  wheel  389008 Mar 23 12:43 t
hello
$ cat > t.go
package main
import "unicode"
var _ = unicode.MaxRune
func main() {
}
$ go build t.go; ls -l t
-rwxr-xr-x  1 andrey  wheel  581024 Mar 23 12:45 t
$ cat > t.go
package main
import "fmt"
var _ = fmt.Println
func main(){
}
$ go build t.go; ls -l t
-rwxr-xr-x  1 andrey  wheel  1481920 Mar 23 12:44 t

Reply via email to