4 ms·
I thought println was like puts in C but it appears to be capable of printing multiple types and support a variable number of arguments(?). It has zero dependen
by BenTheElder 11y ago
I thought println was like puts in C but it appears to be capable of printing multiple types and support a variable number of arguments(?). It has zero dependencies (in theory) and is just a little bootstrapping/diagnostic tool and might even eventually be removed [0]. Importing fmt seems to import the package which adds a lot of bloat to hello world.
But realistically anything more complex than hello world is going to be at least a few MB in go, and eventually you might have to use fmt.Println() and most production code probably does.
Edit: and yes fmt.Println() is idiomatic. I was just mentioning that it is possible for helloworld to be a bit smaller in go than other go programs.
[0] http://golang.org/src/builtin/builtin.go?s=10600:10626#L240 http://golang.org/src/builtin/builtin.go?s=10600:10626#L240
- e12e 11y agoDoing basic imports is a valuable addition to hello world, as it demonstrates the tool-chain is working :-) I just found out that my rustc-arguments probably were wrong (for most uses, anyway). Or rather, they link dynamically to the rust standard library -- which while "equal" to C, won't hold most of the time. All (non-embedded) systems will have libc for the foreseeable future -- assuming that they have rust libstd is probably not a good assumption to make. I found this out after I upgraded to rust-1.0, and the lib/libstd-<hash?>.so files changed names. So while: rustc -O -C prefer-dynamic -o hello hello.rs works, that produces a really dynamically linked little binary. One probably wants: rustc -O -o hello hello.rs This statically compiles in the rust std lib, and leaves a binary that's ~332k after stripping. (Btw, -O is equivalent to -C opt-level=2)