4 ms·
Is that a typical ratio for software ported to Rust? Where is all the extra size coming from?
by andai 5y ago
Is that a typical ratio for software ported to Rust? Where is all the extra size coming from?
- rpeden 5y agoAs someone else mentioned, shared libraries. If you built ls and statically linked libc and whatever else it needs, ls would be a lot bigger.
- est31 5y agoAccording to cargo bloat, 40.1% of the .text section comes from clap, and 46.7% of the .text section comes from std. clap is quite famous to be extremely bloaty. To give an answer to your other question: a lot of the additional code size is a one time cost. That means that the relative difference is the largest in these cases, for binaries with little logic of their own. The more complex the program gets, the less the relative difference is. However, even if you don't account for these one time costs, Rust creates larger programs than C, due to heavy use of generics compared to C.
- Ar-Curunir 5y agoMaybe clap should store text strings in compressed form, and then decompress as needed. Could greatly reduce the bloat.
- mlindner 5y ago.text is the section of the binary where the code is.
- duckerude 5y agoAt least 500K comes from clap, the argument parsing library. That's how much true's size drops if you comment it out. It's a lovely library. Generated help text with colors and line wrapping based on your terminal width, informative error messages that suggest corrections for typos, and a declarative model that lets you express subtle relationships between options. You don't get that from getopt. But it's also pretty large. https://github.com/rust-cli/argparse-benchmarks-rs https://github.com/rust-cli/argparse-benchmarks-rs has some numbers. (Disclaimer: I wrote one of the competitors on that page, lexopt. But I also use clap, depending on the project, and I'm happy with it.)
- camel-cdr 5y agoOut of curiosity, why should each application implement line wrapping for terminals. That seems like a feature the terminal should implement, and from what I've read there is no standard way of getting the terminal size anyway.
- zaarn 5y agoThe terminal isn't aware that you're, for example, using an indent because the help text of an option should appear indented from the option it's explaining. So the line wrap will go into the next line and ruin the readability.
- camel-cdr 5y agoAh, that makes sense.
- ksherlock 5y agoThere's the TIOCGWINSZ ioctl which seems pretty standard.
- twsted 5y ago500K to parse options is frankly too much...
- wongarsu 5y agoIn most software people will care more about helpful error messages and readable help texts than about half a megabyte of code size. Coreutils with its tiny frequently called binaries is an outlier where the size adds up, but that's not the norm.
- 0xedd 5y agoNot sure how you are serious about your reply. PCs are a small market and a solution fitting them hardly represents a valid approach. There is an entire world of small devices that don't vomit terabytes of disk space. One of the most attractive features of Linux is how it suits a large array of hardware. Replacing C solutions with some bloated bandwagon alternative is a bad idea.