r/coolgithubprojects • u/erkamyaman • 5d ago
rust-anything 2.0 is out 🦀 I ported Prettier to Rust in ~17 hours: 19x faster CLI, and all 17,224 recorded runs match byte for byte
It's an open source CLI and MCP server for rewriting an app in Rust and proving the rewrite still behaves the same. The headline test for 2.0 was Prettier.
https://github.com/erkamyaman/rust-anything
How it works
in the repo: jsonin the repo: json
- app record runs the original on thousands of inputs and saves stdout, stderr, the exit code and the files it writes. Optionally it also saves outgoing HTTP, email and database rows.
- A Rust "front door" sits in front of the original. Each piece you port is handled in Rust, and everything else falls back to the original.
- app replay checks every recorded case against the Rust. Nothing counts as done until it's N/N.
- Once nothing falls back anymore, app lift turns it into a pure Rust binary.
My coding agent wrote the Rust. rust-anything gives it ground truth: what to port first, and the exact behavior to match.
Prettier results (Apple M4, two runs each, every output compared before timing)
• CLI, 2,360 JS/TS files: 128.6 s → 6.9 s (19x)
• CLI, 6,305 Markdown files: 352 s → 22.5 s (15.6x)
• GraphQL 17.3x, YAML 17.9x, CSS/SCSS/Less 8.5x
• 17,224/17,224 recorded runs match Prettier byte for byte, across 10 languages
What's not great yet
• 8.1% of cases still fall back to real Prettier. 15,837 of the 17,224 run fully in Rust.
• Calling the Rust doc printer from Node through napi was slower (0.48x). The per-call bridge cost ate the gain. The win comes from the whole CLI being Rust, not from swapping one hot function.
• Replay can only catch what the recording covers. A path no case reaches isn't checked.
Also in the repo: json-server, a whole Node server, became one 5.3 MB Rust binary. Idle memory went from 74 MB to 3.5 MB, and the first response from 79-85 ms to 8-10 ms, with 514/514 recorded HTTP cases matching
New in 2.0
• Side effects: --effects http,smtp and --db-dump. A rewrite that prints the same JSON but sends an email twice now fails replay.
• map: after you pull upstream changes, it tells you which ports are stale.
It supports TS/JS, Python, Go, Ruby, Java and C, with whole-app recording for PHP and C#. MIT licensed.
https://github.com/erkamyaman/rust-anything
The Prettier write-up, with every number and how it was measured, is in docs/real-world.md. I'd really like feedback, especially on what a recording-based check would still miss.
3
u/Interesting_Ad_5676 4d ago
Popular demand -- Please re-write GIMP in rust.
2
u/_mb 4d ago
No c++ support?
1
u/CrossScarMC 4d ago
Prettier in Rust
1
u/Longjumping_Music572 4d ago
Can I ask a few newbie questions? Because if you don't know ask questions.
Does this actually solve real issues? Does this bring real value? By re-writing, does that mean you were reverse engineering? Any program then rewriting it in rust? I would like to find your thought process on this. Am I misunderstanding something here.
0
u/touristtam 4d ago
Do yourself a favour and use
miseandhk.Cool project btw