4 ms·
That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went. OTOH there might be a benefit to
by brabel 5y ago
That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went.
OTOH there might be a benefit too as more code becomes re-usable in independent crates.
- masklinn 5y ago> That's a pretty bad incentive though and you end up with very large dependency trees similar to JS. And we know how that went. That's... not the same thing at all. Rust lets you have multiple crate in a single workspace, which allows parallelising the build (because crates are the concurrency unit of building rust). That's got nothing whatsoever to do with pulling random crates, which is a separate issue.
- yawaramin 5y agoWhy doesn't Rust default to one crate per source file then? Wouldn't that make the build massively parallelized :-)
- howinteresting 5y agoBecause you can have circular dependencies within a compilation unit, but not between units.
- yawaramin 5y agoThat actually sounds more appealing to me. In fact it's exactly how OCaml works. Of course in OCaml compilation units are just files already.
- howinteresting 5y agoI don't think there is a moral justification for circular dependency scopes to always be individual files, especially given that import statements count as circular. The same issue in other languages where circular scopes are individual files leads to some horrible workarounds: * Python TYPE_CHECKING https://adamj.eu/tech/2021/05/13/python-type-hints-how-to-fix-circular-imports/ https://adamj.eu/tech/2021/05/13/python-type-hints-how-to-fi... * C/C++ header files But regardless, there is too much Rust code in existence to change this now.
- yawaramin 5y agoA 'moral' justification is not needed. We are talking about potentially massive build speed improvement here. Sounds like it could just be a build setting.
- howinteresting 5y agoIt would definitely be interesting to run some experiments with automatically splitting up Rust crates into compilation units if possible.
- yawaramin 5y agoUsername checks out :-)
- ATsch 5y ago> you end up with very large dependency trees similar to JS. And we know how that went. The problem in the JS ecosystem is not the number of dependencies, but the number of entities you have to trust. There is no real difference between having one big crate in a repo managed by one entity or fifteen small crates in a repo managed by one entity.