Remix.run Logo
api 19 hours ago

That’s a great point.

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.

The only other kinds of systems that can optimize this way are higher level JIT runtimes like the JVM and CLR. These can treat all code in the VM as a unit and optimize across everything.

TinkersW 17 hours ago | parent | next [-]

  C++ has had whole program optimization since forever. And you can use static linking if you want, the same as Rust.
aleph_minus_one 18 hours ago | parent | prev [-]

> 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 15 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 17 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.