by tene · 12y ago · 0 comments
https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGh...
But shared libraries aren't the only way or even (often) the best way to share code. Especially when we're talking about UNIX tools, it's pretty easy to have one process run another process. Go has a really quick startup time which makes that practical.
I am looking forward to go someday being suitable for producing native shared libraries. If they ever prioritize and complete that work, that's something I'll absolutely be taking advantage of, and will extend the situations where I'm able to reasonably use go.
I guess I'm happy importing everything into monster huge static binaries and not worrying :)
Mono always supported static linking.
http://www.mono-project.com/docs/tools+libraries/tools/linke...
http://www.mono-project.com/docs/advanced/aot/
Sometimes I wish people would not mix toolchains with languages.
Go needs to support shared libraries if it wants to move to the next level of adoption.
So far my view is that I really like the language but I'm finding the tooling pretty unappealing. Wonder if I'm missing a trick?
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.
Modern production environments often involve only one program per VM, or multiple instances of the same program. In such cases, shared libraries are a lose.
I think gccgo allows for .so.
And the work for Android is adding .so support to the main toolchain.
"Unix system programming in OCaml" http://ocaml.github.io/ocamlunix/