DEV Community

aguspdana
aguspdana

Posted on • Updated on

Rust Explorer: A playground that has over 10,000 most downloaded crates

TLDR: Rust Explorer

Image description

A few months ago, I began working on a Rust project that uses a few large dependencies. The compilation took a few minutes on my slow laptop. Every time I make small changes, I had to wait for a few minutes.

My workaround at the time was by creating smaller repl packages. Once they worked I'd copy/paste them into the main package. This is clearly not ideal. Navigating between many packages and copy/paste-ing codes was cumbersome, especially when working on NeoVim.

So I decided to put aside my main project for awhile to build Rust Explorer.

What you can do with it?

  • Use the top 10,000 most downloaded crates in the last 90 days.
  • Set [profile.dev] for benchmarking.
  • Access the internet.
  • Save files and read them on subsequent runs.

Other notable features:

  • Real-time output, useful for working with async code.
  • ASCII color support to spot error easily.
  • Save bins and group them into collections.
  • Revisit execution history.

How it works?

This project is highly inspired by the official playground. In early iterations, I tried to compile the 10,000 crates all at once. But they failed on the first few crates because of issues like version conflict, platform not supported, and system library not found.

I then tried to compile them one by one with all features enabled and skipped crates that failed to compile. Many did fail. The compilation output took so much space that I only managed to compile 1000 crates.

I wasn't happy with the container startup time which (again, on my slow laptop) could take 5s.

I tried to compile to wasm. The startup time was much better, under 1s. But many crates couldn't be compiled to wasm, e.g. rand. Wasm was very limited, so I abandoned it.

After some experiments I arrived at the current version. Each user has a compiler and executor running continuously. This way we don't need to recompile the same dependencies. Plus, we avoid running a new container on every run.

With collections, we can use Rust Explorer like a jupyter notebook. For example one bin is used for downloading and writing csv files. And other bins are used to query the data.

Here are some examples:

I hope this project could be useful for some Rust devs too.

Top comments (0)