3 ms·
Supply chain incidents suck and we need to do better. Personally for rust I’m a proponent of the foundation supporting a few core crates that go under the same
by vsgherzi 5mo ago
Supply chain incidents suck and we need to do better. Personally for rust I’m a proponent of the foundation supporting a few core crates that go under the same audit procedure as the main rust language and give funding to the project to limit supply chain vulns. I don’t think the right answer is to remove systems like crates or npm. Crate and npm are a boon for many developers.
- vsgherzi 5mo agoCrates has also been making efforts to include rust sec, but in addition to the above I would like the community to shy away from many small dependencies to a few larger ones just as tokio has
- fleventynine 5mo agoMany small crates published by large, trustworthy projects are fine and preferable to one large crate that "does everything".
- vsgherzi 5mo agoYeah I’d agree that multiple crates under one project is basically the same as 1 large crate. The real problem is how many people you’re trusting and it’s all coming from the same person.
- zbentley 5mo agoWhy? Honest question. Commons, Guava, Spring, and more seem to take this approach successfully (as in, the drawbacks are outweighed by the benefits in convenience, quality, and security) in Java. Are benefits in binary size really worth that complexity? And before someone says “just have a better standard library”, think about why that is considered a solution here. Languages with a large and capable standard library remain more secure than the supply-chain fiascos on NPM because they have a) very large communities reviewing and participating in changes and b) have extremely regulated and careful release processes. Those things aren’t likely to be possible in most small community libraries.
- xg15 5mo agoYou will have lots of dead code in your build. That dead code might have "dead dependencies" - transitive dependencies of its own, that it pulls in even though they are not actually used in the parts of the crate you care about. In the worst case, you can also have "undead code" - event handlers, hooks, background workers etc that the framework automatically registers and runs and that will do something at runtime, with all the credentials and data access of your application, but that have nothing to do with what you wanted to do. (Looking at you, Spring...) All those things greatly increase the attack surface, I think even more than pulling in single-purpose library.
- tardedmeme 5mo agoLibraries like Guava and Commons don't have transitive dependencies - they are self contained except for other parts of the same library.
- rcxdude 5mo agoThe same issue occurs whether you bundle all the code together or not, it's just that if you bundle it together you don't see what's happening and you can't use only part of it easily.
- pornel 5mo agoWhy? It's the essence of "Simple Made Easy": you don't have other code to complect with. You have a smaller interface, focused on a singular goal. When a library has to work as a standalone project, it can't be accidentally entangled with other components of a larger project. Smaller implementations are also easier to review against malware, because there are fewer places to hide. You don't have to guess how a component may interact with all the other parts of a large framework, because there aren't any. There are also practical Rust-specific concerns. Fine-grained code reuse helps with compile times (a smaller component can be reused in more projects, and more crates increase build parallelism). It makes testing easier. Rust doesn't have enough dynamic monkey-patching for mocking of objects, so testing of code buried deep in a monolith is tricky. Splitting code into small libraries surfaces interfaces that are easily testable in isolation. It helps with semver. A semver-major upgrade of one large library that everyone uses requires everyone to upgrade the whole thing at the same time, which can stall like the Python 2-to-3 transition. Splitting a monolith into smaller components allows versioning them separately, so the stable parts stay stable, and the churning parts affect smaller subsets of users.
- kibwen 5mo agoContrary to what the article here presents, Rust does not have a culture of microlibraries like NPM does. The author and their LLM are cargo-culting a criticism of Rust made by people whose only experience is with the Node ecosystem. The Rust stdlib may not be especially "wide" compared to languages like Python, but it is quite deep, with the objective of making it so that you don't feel the need to publish single-purpose libraries which only exist to fix papercuts. Dozens of new APIs get added with every Rust release, which, occurring every six weeks, amounts to hundreds per year.
- MarsIronPI 5mo agoWhat are you talking about? Every Rust project I see seems to have 5 dependencies that do some simple thing that should be in the standard library, or at least in some centrally-audited monolibrary of utilities.
- ChrisSD 5mo agoCan you name 5 as an example?
- DreadY2K 5mo agoNot GP but I feel like there's a continual process of the stdlib adding some new functionality to make one such crate redundant (e.g. is-terminal in 1.70), but it isn't done yet.
- ChrisSD 5mo agoYep, that's why I was asking. I'd be very interested to hear of more candidates for uplifting into std. I guess saying "every project" has 5 dependencies might be somewhat hyperbolic (or at least domain specific) but it would be interesting to know the kinds of things they're talking about that haven't yet been uplifted.
- kibwen 5mo agoPerhaps you're referring to things like regex and rand (each of which is itself multiple crates for the purpose of code organization), which are all first-party crates provided by the Rust organization itself, simply shipped and versioned separately from the standard library? If you trust the Rust organization enough to install and run the provided toolchain binaries on your machine, then you trust them enough to depend upon the dozens of crates that are provided under the umbrella of the Rust project.
- suprfsat 5mo agodo we really need both npm and nmp though
- fragmede 5mo agoand pnpm
- MarsIronPI 5mo agoYou forgot pnmp! How can you not be using pnmp in 20267!?
- rmoriz 5mo agoJust use the implementation of petty, a js runtime written in Zag that is just rewritten by AI in Rust. It will be memory safe.
- PunchyHamster 5mo agonah, remove NPM, nothing good comes out of that.
- 2ndorderthought 5mo ago[dead]
- hacker_homie 5mo agoMove high value crates into the standard library?
- orf 5mo agoPlease no, that’s a terrible outcome.
- pixl97 5mo agoWhat else would you suggest that also does not have terrible outcomes. The situation as is, is untenable.
- vsgherzi 5mo agoAs I said above “Personally for rust I’m a proponent of the foundation supporting a few core crates that go under the same audit procedure as the main rust language and give funding to the project to limit supply chain vulns. I don’t think the right answer is to remove systems like crates or npm. Crate and npm are a boon for many developers.” This is my solution. We get the quality of a std lib without forcing it in the std Lib and without extra maintaining cost for the team
- vsgherzi 5mo agoThis bloats the std library and forces lots more work and stress on the rust dev team. Not to mention it’ll add more churn to the std lib.
- dijit 5mo agohonestly I thought this was the end goal of blessed.rs
- kibwen 5mo agoA ton of the most popular crates on crates.io are already first-party crates provided by the Rust organization itself. This is often overlooked when people are wringing their hands about Rust crate graphs. Looking at the top 10 list of most-downloaded crates on the front page of crates.io, the only one not either from the Rust organization or from a Rust core maintainer is the base64 crate.