Rust is described as "fast and memory-efficient" of its performance, but why the exe file seems not like this?
#main.c
#include "stdio.h"
int main() {
printf("Hello, world!\n");
return 0;
}
#src/main.rs
fn main() {
println!("Hello, world!");
}
My compiler is MinGW-gcc. The size of the exe file compiled from main.c is 53k, but that from main.rs is 3474k in release mode. How should I look at the performance of Rust versus C?
I don't think binary size is usually included when considering performance, though it can of course be a relevant metric to consider in some contexts. The bulk of the difference is due to Rust binaries being statically linked, I believe. This blog post is a few years old, but still relevant I think: Rustlog : Why is a Rust executable large?
If you want to have small binaries you can give UPX(https://upx.github.io/) a chance. But please be careful if execution performance and RAM usage. But it creates small binaries with a cost of higher starting time and its using more RAM.