Live data from Hacker News

Rust’s dependencies are starting to worry me

vincents.dev

231–240 of 593 posts

Re: Rust’s dependencies are starting to worry me

#231
I agree that there are too many dependencies in Rust. I support the idea of adding some of the more popular crates to std. Many applications use something like tracing, tracing-subscriber, and basic server/client functionality. It would be great to have simple, minimal-feature implementations of these in std — similar to how Go does it. If someone needs a more complex system, they can still use an external crate, but having basic building blocks in std would really help.

Re: Rust’s dependencies are starting to worry me

#233
I recently wrote an extremely basic Rust web service using Axum. It had 10 direct dependencies for a total of 121 resolved dependencies. I later rewrote the service in Java using Jetty. It had 3 direct dependencies for a total of 7 resolved dependencies. Absolutely nuts.

Re: Rust’s dependencies are starting to worry me

#234
post #29

A true enough statement, but "Rust" is unnecessarily specific. Dependencies are getting scary in general. Supply chain attacks are no longer hypothetical, they're here and have been for a while. If I were designing a new language I think I'd be very interested in putting some sort of capability system in so I can confine entire library trees safely, and libraries can volunteer somehow what capabilities they need/offe…

I don't think you need to get very complex to design a language that protects libraries from having implicit system access. If the only place that can import system APIs is in the entry program, then by design libraries need to use dependency injection to facilitate explicit passing of capabilities.

One can take just about any existing language and add this constraint, the problem however is it would break the existing ecosystem of libraries.

Re: Rust’s dependencies are starting to worry me

#235
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…

As far as I'm aware, LTO completely solves this from a binary size perspective. It will optimise out anything unused. You can still get hit from a build time perspective though.

LTO gets a lot of the way there, but it won't for example help with eliminating unused enums (and associated codepaths). That happens at per-crate MIR optimisation iirc, which is prior to llvm optimisation of LTO.

Re: Rust’s dependencies are starting to worry me

#236

Earlier quoted context omitted.

As far as I'm aware, LTO completely solves this from a binary size perspective. It will optimise out anything unused. You can still get hit from a build time perspective though.

yes, it's not a issue of code size but a issue of supply chain security/reviewability it's also not always a fair comparison, if you include tokio in LOC counting then you surely would also include V8 LOC when counting for node, or JRE for Java projects (but not JDK) etc.

And, reductio ad absurdum, you perhaps also need to count those 27 million LOC in Linux too. (Or however many LOC there are in Windows or macOS or whatever other OS is a fundamental "dependency" for your program.)

Re: Rust’s dependencies are starting to worry me

#237

To address a point near the end of the article, here is my [partial] solution that works as a baseline. Curate a collection of libraries you use and trust. This will probably involve making a number of your own. Wheel-reinvention, if you will. If done properly, even the upfront time cost will save in the long-run. I am in the minority here, but I roll my own libs whenever possible, and the 3rd party libs I use are of…

Rust really made some unfortunate choices with async, it pollutes everything but isn't generic enough so now you are married to the runtime, this bifurcates the whole ecosystem. It is nearly phobos/demios problem from Dlang, but instead Tokio just took over. One doesn't use Rust anymore, they use Tokio.

Rust will thrive despite the PLT coloring debate. Async frameworks often dominate through winner-takes-all dynamics. Most blog posts on async coloring are pretentious nonsense, and I've faced heavy moderation here for calling out their intellectual bankruptcy. The completely brain dead moralizing arguments from the ignorant deserve intense derision regardless of what HN's official rules are.

Real world software ecosystems evolve slowly, requiring years of debate to shift.

- From HN's most outspoken Rust critic

Re: Rust’s dependencies are starting to worry me

#238
post #96

Earlier quoted context omitted.

LTO only gets you so far, but IMO its more kicking the can down the road. The analogy I use is cooking a huge dinner, then throwing out everything but the one side dish you wanted. If you want just the side-dish you should be able to cook just the side-dish.

Then another group of armchair programmers will bitch you out for using small dependencies I just don't listen. Things should be easy. Rust is easy. Don't overthink it

Some of that group of armchair programmers remember when npm drama and leftpad.js broke a noticeable portion of the internet.

Sure, don't overthink it. But underthinking it is seriously problematic too.

Re: Rust’s dependencies are starting to worry me

#239

> do I even need this crate at all? 35 lines later I had the parts of dotenv I needed. I'm not saying you copy-pasted those 35 lines from dotenvy, but for the sake of argument let's say you did: now you can't automatically benefit from dotenvy patching some security issue in those lines.

Can't benefit from them patching a security issue, but don't suffer from

  - them breaking something
  - a supply chain attack
  - them making a change which breaks your program
  - you having accidentally relied on a bug or an unintended behavior of their code
    (which they may fix at any moment)
  - many unneeded LOC in your codebase
  - absolution of ownership
    - relying on a dependency versus having written it yourself
    - in the latter case you'll automatically take responsibility
    - think much more about code's security/quality
    - have the knowledge to fix it and know exactly where to
      (in your 35-lines of code you yourself wrote)
  - more burdensome upgrades of your software
  - longer compilation speeds
  - having to monitor their program
    - is it abandoned, ownership transferred to dubious party
    - did the maintainer have a late night drunken stupor accepting bad pull requests
    - did they react to a CVE or not
    - did they change the license
    - do they have a license but added their own problematic paragraph
    - does the program "develop badly"
      (change its target scope in any problematic way)
      (take on more and more bloat, more unneeded functionality)
  - having worse of an overview of your total dependencies 
    (since they may themselves rely on further crates you don't expect)
  - ...
what's the trade-off now?

Re: Rust’s dependencies are starting to worry me

#240
> What's the solution?

A proper 'batteries included' standard library in the language and discouraging using too many libraries in a project.

The same mistakes from the Javascript community are being repeated in front of us for Cargo (and any other project that uses too many libraries).

Post reply on HN