I find the approach and the way they define the language in the first two chapters of the documentation particularly interesting. So I decided to get my fingers wet and started out with "Hello, world!".
I did so on Windows 7 x64, btw.
fn main() {
println!("Hello, world!");
}
Issuing cargo build
and looking at the result in targets\debug
I found the resulting .exe
being 3MB. After some searching (documentation of cargo command line flags is hard to find...) I found the --release
option and created the release build. To my surprise, the .exe size has only become smaller by an insignificant amount: 2.99MB instead of 3MB.
My expectation would have been that a systems programming language would produce something compact.
Can anyone elaborate on what Rust is compiling to, how it can be possible it produces such huge images from a 3-line program? Is it compiling to a virtual machine? Is there a strip command I missed (debug info inside the release build?)? Anything else which might allow to understand what is going on?
min-sized-rust
for an overview all of all of the different techniques to minimize binary size of Rust applications. – Exception