Live data from Hacker News

Rust’s dependencies are starting to worry me

vincents.dev

501–510 of 593 posts

Re: Rust’s dependencies are starting to worry me

#501

No mention here of binary size (beyond linking out to a ClickHouse blog post on the topic). The total number of lines of code is relevant, sure, but for most practical purposes, compile times and binary sizes are more important. I don't know the situation in Rust, but in JS land, there's a pretty clear divide between libraries that are tree-shakable (or if you prefer, amenable to dead code elimination) and those that…

Like many compiled languages, Rust does dead code elimination on everything.

Re: Rust’s dependencies are starting to worry me

#502
post #421

Earlier quoted context omitted.

> At each level a caller might need 5% of the functionality of any given dependency. The deeper the dependency tree gets the more waste piles on. Eventually you end up in a world where your simple binary is 500 MiB of code you never actually call, but all you did was take that one dependency to format a number. I'm not convinced that happens that often. As someone working on a Rust library with a fairly heavy depende…

I was very 'impressed' to see multiple SSL libraries pulled into rust software that never makes a network connection.

Did you dig any deeper over which paths that was pulled in?

Re: Rust’s dependencies are starting to worry me

#503

No mention here of binary size (beyond linking out to a ClickHouse blog post on the topic). The total number of lines of code is relevant, sure, but for most practical purposes, compile times and binary sizes are more important. I don't know the situation in Rust, but in JS land, there's a pretty clear divide between libraries that are tree-shakable (or if you prefer, amenable to dead code elimination) and those that…

> The total number of lines of code is relevant, sure, but for most practical purposes, compile times and binary sizes are more important.

Perhaps for most practical purposes, but not for security, which the article's author seems more concerned with:

> Out of curiosity I ran toeki a tool for counting lines of code, and found a staggering 3.6 million lines of rust... How could I ever audit all of that code?

Tree-shaking can't help with that.

Re: Rust’s dependencies are starting to worry me

#504

> What's the solution? Big things you use off-the-shelf libraries for. Small things you open-code, possibly by cribbing from suitably-licensed open source libraries. You bloat your code to some degree, but reduce your need to audit external code and reduce your exposure to supply chain attacks. Still, the big libraries are a problem, but you're not going to open code everything. This isn't just Rust. It's everything.

> Big things you use off-the-shelf libraries for.

I should have added: "and for obvious reasons".

Didn't computer science hype up code reuse for decades before it finally started happening on a massive scale? For that to actually happen we needed programming languages with nice namespaces and packaging and distribution channels. C was never going to have the library ecosystem that Java, C++, and Rust have. Now that we're there suddenly we have a very worrisome supply chain issue, with major Reflections on Trusting Trust vibes. What to do? We can't all afford to open-code everything, so we won't, but I recommend that we open-code all the _small_ things, especially in big projects and big libraries. Well, or maybe the AI revolution will save us.

Re: Rust’s dependencies are starting to worry me

#505

No mention here of binary size (beyond linking out to a ClickHouse blog post on the topic). The total number of lines of code is relevant, sure, but for most practical purposes, compile times and binary sizes are more important. I don't know the situation in Rust, but in JS land, there's a pretty clear divide between libraries that are tree-shakable (or if you prefer, amenable to dead code elimination) and those that…

Like many compiled languages, Rust does dead code elimination on everything.

Right, but it depends on how the code is written, right?

If you use mostly free functions things will shake out naturally, if you use lots of dynamic dispatch you'll pull in stuff that doesn't get called.

Re: Rust’s dependencies are starting to worry me

#506

Earlier quoted context omitted.

> but neither Go or C# have issues with dependency hell like Rust or even more JavaScript, because they have exceptional std libs They also have a lot narrower scope of use, which means it is easier to create stdlib usable for most people. You can't do it with more generic language.

I didn't understand the embedded systems argument. Just because a standard lib is large doesn't mean it all ends up in the compilation target.

Indeed, it has no bearing on binary size at all, because none of it will be included. If you are coming from the perspective where the standard library is entirely unusable to begin with, then improving the standard library is irrelevant at best. It also likely means that at least some time and effort will be taken away from improving the things that you can use to be spent on improving a bunch of things that you can't use.

I feel like this is an organizational problem much more than a technical one, though. Rust can be different things to different people, without necessarily forcing one group to compromise overmuch. But some tension is probably inevitable.

Re: Rust’s dependencies are starting to worry me

#507

Earlier quoted context omitted.

> At each level a caller might need 5% of the functionality of any given dependency. The deeper the dependency tree gets the more waste piles on. Eventually you end up in a world where your simple binary is 500 MiB of code you never actually call, but all you did was take that one dependency to format a number. I'm not convinced that happens that often. As someone working on a Rust library with a fairly heavy depende…

Not in Rust, but I've seen it with Python in scientific computing. Someone needs to do some minor matrix math, so they install numpy. Numpy isn't so bad, but if installing it via conda it pulls in MKL, which sits at 171MB right now (although I have memories of it being bigger in the past). It also pulls in intel-openmp, which is 17MB. Just so you can multiply matrices or something.

MKL is usually what you want if you are doing matrix math on an Intel CPU.

A better design is to make it easy you to choose or hotswap your BLAS/LAPACK implementation. E.g. OpenBLAS for AMD.

Edit: To be clear, Netlib (the reference implementation) is almost always NOT what you want. It's designed to be readable, not optimized for modern CPUs.

Re: Rust’s dependencies are starting to worry me

#508

Earlier quoted context omitted.

Yet Maven repository is still not that bloated even after 20+ years Java et al. being one of the most popular language. Compared to Rust where my experience with protobuf lib some time ago was that there is a choice of not 1 but even 3 different libraries, one of which doesn't support services, another didn't support the syntax we had to support, and the third one was unmaintained. So out of 3 choices no single one w…

More time enables more consolidation.

No, there were never several unofficial libraries, one of which eventually won the popularity contest. There was always only one official. There is some barrier to add your project there, so might be that helped.

It's even more pronounced with the main Java competitor: .Net. They look at what approach won in Java ecosystem and go all in. For example there were multiple ORM tools competing, where Microsoft adopted the most popular one. So it's even easier choice there, well supported and maintained.

Re: Rust’s dependencies are starting to worry me

#509
post #85

IMO any system where taking a dependency is "easy" and there is no penalty for size or cost is going to eventually lead to a dependency problem. That's essentially where we are today both in language repositories for OSS languages and private monorepos. This is partly due to how we've distributed software over the last 40 years. In the 80s the idea of a library of functionality was something you paid for, and painsta…

> At each level a caller might need 5% of the functionality of any given dependency.

I think that is much more of a problem in ecosystems where it is harder to add dependencies.

When it is difficult to add dependencies, you end up with large libraries that do a lot of stuff you don't need, so you only need to add a couple of dependencies. On the other hand, if dependency management is easy, you end up with a lot of smaller packages that just do one thing.

Re: Rust’s dependencies are starting to worry me

#510

Earlier quoted context omitted.

I have a lot of sympathy for this viewpoint, but I also ask that we try to remind ourselves. We are asking for professionalism from hobby projects. If you want a mature protobuf implementation you should probably buy one. Expecting some guy/gal on the internet to maintain one for your for free seems ill advised.

> I have a lot of sympathy for this viewpoint, but I also ask that we try to remind ourselves. We are asking for professionalism from hobby projects. Nobody is asking for professional quality standards from hobby projects. At best, they are asking for hobby projects to advertise themselves as such, and not as "this is a library for [x] that you can use in your stuff with the expectations of [maintenance/performance/c…

> At best, they are asking for hobby projects to advertise themselves as such

That's also work. You don't get to ask the hobby programmer to do your work of vetting serious/maintained projects for you. As the professional with a job, you have to do that. If some rando on GitHub writes in their readme that it's maintained, but lies. You're the idiot for believing him. He's probably 12 years old, and you're supposedly a professional.

> No software is ever developed this way.

That's just inaccurate. In my day job we pay for at least 3-4 3rd party libraries that we either have support contracts on or that were developed for us along with a support contract. Besides those there's also the myriad of software products, databases, editors, Prometheus, grafana, that we pay for.

Software people really underestimate how much business guys are willing to pay for having somebody to call. It's not "infinitely scalable" in the way VC's love, but it's definitely a huge business opportunity.

Post reply on HN