2 ms·
Way to prove me wrong about reply guys. Rust binaries are large for small utilities. What kind of C are you comparing it to, Windows?
by garbagecoder 4y ago
Way to prove me wrong about reply guys. Rust binaries are large for small utilities. What kind of C are you comparing it to, Windows?
- tialaramex 4y agoYou expressed an opinion about the runtime. If your complaint is actually that your Rust binaries are big, that's a different thing. The "reply guy" knows what a runtime is. In a language like Java of course the entire Java Virtual Machine is a runtime. There are lots of nice things to like about this, but it's pretty heavyweight. In C and Rust the usual application software is built with a runtime, it just doesn't do very much. For example the runtime makes the world for your software hospitable before your main() function executes and it needs to arrange that atexit() work for example. Rust's runtime does a little more than C's but not a whole lot. Both C and Rust have a mechanism to write software for an environment where you just wake up naked and setting up even the basic hardware is your problem, as might happen on a tiny embedded SOC too small for an operating system - C calls this "freestanding" and Rust calls it "no_std" but that's not the default. The new complaint your have though is about binary size - your Rust binaries are big often because of mono-morphisation, a compiler optimisation pass which converts all the polymorphic functions used in your program into distinct instances of that function for each type used, possibly inlining some of them where they're used; and because it's statically linked so the binary ends up with all this stuff in it even if that same stuff would be used by other binaries. It's not big because there's some massive runtime living in the binary.