i ran through the rust “getting started” page ( it's a hello-world project that has the rust crab mascot say hello, and consists of 10 lines of code actually written.

it results in pulling in 25 separate dependencies totalling up to 97 megabytes.

for reference the entire cowsay source is 168 lines/4 kilobytes of perl.

@nytpu I think they're trying to recreate nodejs package management for systems programming. That's the main objective of rust, right?

@nytpu more on the ferris-says library's authors; clap is arg parsing, which shouldn't be pulled in because we're just using it as a library, not a command-line program; error-chain is a convenience thing for error types and could easily be gotten rid of (which pulls in a bunch of stuff), smallvec is tiny, textwrap seems like a fine dependency (who wants to reimplement all that junk), and unicode-width is self-explanatory.

@nytpu Not to say that's not surprising, but perl packages on my machine appears to be 162MB. :/

@cstanhope But that's for all perl stuff on your system, cowsay itself uses precisely zero (0) external dependencies, only perl core modules that are always bundled with every perl install. These rust deps are all required by the hello-world program specifically, and even worse they're all indirect dependencies that I didn't even explicitly add.

@nytpu True, it's not an apples to apples comparison. I didn't try to exclude perl packages I never explicitly installed. So, does the resulting executable need all 97MB? Or is that just from all the build cruft?

(And I don't mean to bother you. I've been meaning to go and learn some Rust, so maybe I should go do that now and not pester somebody on the internet.)

@cstanhope This was a while ago so I don't remember in this particular case, but I presume rust's linker would be smart enough to strip out all the unused cruft. Rust does make huge executables though, even when stripped, and I really can't figure out why. Unstripped Go binaries with debug symbols and with the full Go runtime and everything are much smaller than a stripped rust binary (and rust doesn't have a runtime)

I've written about this before funnily enough:

@nytpu Oh geez. I didn't see the date of the post I was replying to. Sorry to jump on an old post. Thanks for the additional info. I'm digging in now for myself. It looks like the resulting release binary is around 413kB, with dynamic dependencies of libs: gcc, pthread, dl, c, and ld-linux-x86-64.

The debug build is about 1MB.

Thanks for the kind response and link, and thanks for the prompt to finally tentatively start exploring rust. :)

@cstanhope @nytpu Doesn't answer the original question, but Rust has been used for a winning 4k intro:

So it's not like it can't be small, it's just that the package ecosystem has issues.
The bigger issue to me is that if you build a different executable, all the shared dependencies are compiled again. Compiling any Rust package on Guix is a bit of a nightmare.

@csepp @cstanhope I always have to emphasize this, but I don't hate rust itself, I hate the rust community for a variety of reasons, one being their obsession with emulating NPM and javascript dependencies, and also for their hubris to say "rewrite everything in rust" (I've never seen another community where the majority unironically claims that their language is perfect for all use-cases). I also dislike the lack of a spec, and the rust team's proclivity of "add more features before fixing and/or improving existing ones." Also dislike that you need to use proprietary webshit github to be able to use (not even Go stoops low enough to force you to do that)

Agreed! #rust's #cargo build-system is cruft. Even when reusing a crate from the very same filesystem-place, it gets compiled again for each package using it
@cstanhope @nytpu

@nytpu i don't think that's entirely fair. rust is compiled, which means your build directories are going to have a lot of intermediate outputs and build files. try building with cargo build --release and measure the size of the actual output binary (target/release/<binary name>)

@boilingsteam Well yeah, that comes with the territory of webshit development, but rust is billed as a """"systems programming language""""

@nytpu One can safely assume that Rust is not optimized for minimizing dependencies for a hello world.

@nytpu They could have created that library without importing any dependencies. But the website is just demonstrating how to import a crate and use it.

@mmstick Well yeah, but it was amusing to have someone on irc bill it as the best new systems programming language and then the first experience I ever had with it was pulling in 25 dependencies for a hello world. And I'm not criticizing it for using a dependency, I'm criticizing it for using that many for such a simple library, and then them deciding that that was the perfect library to use when introducing people to the language. In my mind when I saw that, I figured it was emblematic of the community as a whole that using that many dependencies for a few lines of code was not considered strange or unusual (and yes, this does turn out to be true in most of the real rust code I've seen)

ferris-says is even more amazing because it's less flexible than cowsay, it can only print out just the rust crab saying something, so it's not even loading other characters like cowsay can. I understand the command line flag parser when it's used as a standalone program, but it should not be pulling that in (and compiling it!) when I'm using its library functionality. The only thing it should reasonably be using is the unicode library, which in itself shouldn't need any other dependencies, libicu for C and C++ certainly doesn't (

@nytpu My experience, as a person that's been writing Rust since 2015, is that most Rust crates aren't importing other crates for no reason at all.

The reason ferris-says imports so many dependencies is that it's importing the clap crate. The clap crate is only used by command line applications wanting to have a professional command line argument parser. My guess is that the library also contains a binary target which is using clap, but you get to fetch clap too since it's not separated.

@nytpu And it's a little late to say someone on IRC is billing it as the best systems programming language. That's already been decided by Intel, the Linux kernel, GNOME, Red Hat, Microsoft, Apple, Google, and virtually everyone else.

@nytpu I brought this up with the maintainer of the ferris-says crate and they fixed the dependency issue. It no longer pulls in the clap crate because the binary project has been separated from the library, and some of the few remaining crates were removed because they aren't actually used by the crate. They were simply fetched because they're defined in the Cargo.toml, even if they never got compiled and linked.

@nytpu That sounds a little excessive! And it's scary 'cause Rust takes soo much memory and time to compile!

Sign in to participate in the conversation

masto instance for the tildeverse