Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> issues of having such a mess of abstractions, the resulting binaries are literally magnitude larger

They're significantly larger, yes -- it's a fair complaint of rust. But it's mostly because of static linkage AFAIK [1] and not "a mess of abstractions".

[1] https://github.com/uutils/coreutils/issues/747



And what do you think pulls in all the symbols for static linking? Maybe the mess of abstractions perhaps?


Actually, the culprit is Rust's decision to statically link its standard library and all its dependencies by default.

Things like libunwind, libbacktrace, embedded debugging symbols for backtraces, and the jemalloc allocator aren't free.

If you ask for dynamic linkage (with the caveat that Rust doesn't have a stable ABI yet), you get a ~8K Hello World binary.

It's also possible to prune down the statically-linked size by opting out of various conveniences like jemalloc. (They're working toward making the system allocator default but don't want to regress Servo in the interim.)

...and if opt into static linking with GCC and G++ (and ask Rust to make its link to libc static), Rust can actually outdo them on a Hello World.

Here's a detailed exploration: https://lifthrasiir.github.io/rustlog/why-is-a-rust-executab...


> Actually, the culprit is Rust's decision to statically link its standard library and all its dependencies by default.

No it really isn't, static linking does not imply bloat as commonly perpetuated.

> It's also possible to prune down the statically-linked size by opting out of various conveniences like jemalloc

Try this: opt out of everything except the standard library, create something somewhat trivial and idiomatic in both rust and c, compile and see what you get.

> Rust can actually outdo them on a Hello World.

Hello word is hardly a use of the standard library.


> No it really isn't, static linking does not imply bloat as commonly perpetuated.

I never said it implied bloat. I said that, if you ask Rust to link dynamically despite the lack of a stable ABI, you'll get binaries of a size similar to C and C++.

> Try this: opt out of everything except the standard library, create something somewhat trivial and idiomatic in both rust and c, compile and see what you get.

I'll need you to be a bit more specific than "somewhat trivial", given that "Hello world" uses println! or printf() but you consider it ineligible.

> Hello word is hardly a use of the standard library.

println! aside, it's a data point and that's all I meant by it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: