▲ | aleph_minus_one 16 hours ago | |
> Another advantage is that at least for Rust you can do whole program optimization. The entire program tree is run through the optimizer resulting in all kinds of optimizations that are otherwise impossible. I get why this might lead to big intermediate files, but why do the final binaries get so big? | ||
▲ | uecker 13 hours ago | parent | next [-] | |
Both C++ and Rust are based on monomorphization, which means generic programming is based on a expansion of code for each combination of types. This makes compilation slow and causes code bloat. One then needs whole program optimization to get this under control to some degree. | ||
▲ | 3836293648 16 hours ago | parent | prev [-] | |
Rust binaries + all their dynamic libraries are the same size as C++ binaries + their linked libraries (when stripped, this isn't default in Rust) The main issue is that Rust binaries typically only link to libc whereas C++ binaries link to everthing under the sun, making the actual executable look tiny because that's not where most of the code lives. |