I don't know about Go, so I can't speak for that. With Rust, you're seeing these sizes due to static linking, and symbols being included in the binary. On Linux, a hello-world compiled with --release generates a 3.7M executable. Just running strip on this executable reduces the size to 310k. You can also se size-related optimizations in your profile:
[profile.release]opt-level="z"lto=true
Other tweakables include panic behavior - you can remove the unwinding mechanism using this:
[profile.release]panic="abort"
So, yes, while the defaults produce some hefty executables, Rust does expose tools to more finely tweak your result. This repo provides a much more comprehensive overview.
Thanks for the answer. This is just a start for my journey of Rust. I have a plan to try it for web backend after reading your post about it. We know that the book also has a chapter on web server that I can use for starting point.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't know about Go, so I can't speak for that. With Rust, you're seeing these sizes due to static linking, and symbols being included in the binary. On Linux, a
hello-world
compiled with--release
generates a 3.7M executable. Just runningstrip
on this executable reduces the size to 310k. You can also se size-related optimizations in your profile:Other tweakables include panic behavior - you can remove the unwinding mechanism using this:
So, yes, while the defaults produce some hefty executables, Rust does expose tools to more finely tweak your result. This repo provides a much more comprehensive overview.
Thanks for the answer. This is just a start for my journey of Rust. I have a plan to try it for web backend after reading your post about it. We know that the book also has a chapter on web server that I can use for starting point.