Avatar ·

Why are Rust executable files so huge and how to fix it?

Hi everyone! I'm new to Rust and noticed a strange thing: even the simplest program takes up megabytes. I wrote "Hello, world!":\n\n```rust\nfn main() {\n println!("Hello, world!");\n}\n```\n\nCompiled it with `cargo build` and got a file of 3.5 MB! For comparison, a similar program in C takes only 16 KB. I understand that Rust is not C, but the 200x difference is concerning.\n\nI tried adding `--release` — it became 2.8 MB. Still huge. And I'm not using any external crates, only the standard library. My project is a regular binary with no extra dependencies.\n\nI've heard that Rust statically links the standard library, but is it really that big? Go also uses static linking, but their binaries are smaller. Maybe I'm doing something wrong? Is there a way to