I'm mapping ALL crates.io and their dependencies.

These are just 14341 crates (palindrome number and about 5.9% of crates.io) and it already seems something of cosmical proportions. Like some sort of megastructure. And we have some data!

Out of 14341 crates, 46% depend directly on tokio, 4.8% depend directly on syn, only 44 depend on a rustc_* internal crate, almost all of them being rustc_version and even being the most downloaded crate of all crates.io, only 166 depend on `hashbrown`.

#rust #opensource #foss

Fun facts about the graph:

There are 615 crates without any dependencies, those can be seen on up right.

Down right, with a big red cloud are AWS Rust crates, which ALL depend on `tokio` but not `syn`, `clap` or `hashbrown`. Curious.

On cyan to its side, Google crates.

Here is the color code:
Yellow - Syn
Light green - Clap
Not so light green - Rand
Red - Tokio

Tokio is put last because if it's first, maybe 70% of that big cloud is red and that's not interesting.

@blyxyas
Only 46% depend on tokio?
@mikalai 46% directly depend on tokio (as in it's directly depended on in Cargo.toml). I still have to do some processing, but I imagine that much more indirectly depend on it.
@mikalai @blyxyas I'm actually surprised it's that high. Tokio seems to most often be used as a dependency by applications, not libraries. If you don't need async file I/O or task scheduling you can write async code in a library using just std::future.
@tedmielczarek @mikalai This 14K crates are the most recently updated ones (so, the ones that have updated in the last ~50 days). So that might skew up some results (maybe these last two months there have been more binaries updated on crates.io).
@tedmielczarek @mikalai @blyxyas if I were writing such a library (which I'm not, so ignoramus here), I would likely make some integration tests, and wouldn't those use tokio?

@gthb @mikalai @blyxyas you'd list tokio in dev-dependencies in that case: https://doc.rust-lang.org/rust-by-example/testing/dev_dependencies.html

I don't know the exact methodology used to generate the graph but it seems reasonable to treat dependencies and dev-dependencies separately.

Dev-dependencies - Rust By Example

Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries.

@tedmielczarek @mikalai @blyxyas right, I was assuming dev-deps were included, but no reason to assume that. And I bet the difference is interesting in its own right!
@blyxyas How does this take into account optional features? Tons of crates (like my `time`) depend on `serde` and `rand`, but it's entirely opt-in.
@jhpratt They are still taken into account as dependencies, maybe the links between these could have less opacity, but it wouldn't be noticeable at full scale.
@blyxyas
Question.
Is it possible, in Rust, to just use type definitions without any code being used, like when type is used? Are there situations like it?
This question is induced by "import type" mechanics in TypeScript. But, does low-level language always have code to add?

@mikalai I guess it's possible, but if only type definitions are used, everything will be ran at compiletime and thus no output will be user-visible.

I've seen someone run factorio just with Rust types, so everything is possible in the weird realm of type theory

@blyxyas
... beloved realm of types ... usage in practice