r/coolgithubprojects • • 2d ago

rust-anything turned Ruby’s Shellwords into Rust: 5x faster, all identical

Post image

rust-anything takes one unit of an existing codebase (Ruby, Python, TS, Go, Java, C, PHP, C#), records what the original actually does, builds a Rust port behind a bridge, and diffs every recorded case before you switch anything over.

Repo: https://github.com/erkamyaman/rust-anything

The GIF is Ruby's standard-library shellwords.rb:

- diff: all 1617 recorded calls give identical results and errors.

- bench (per call, crossing the Ruby/Rust boundary included): shellsplit 3.17x, shelljoin 5.82x, shellescape 6.83x. 5.01x overall.

- Batch: 50,000 mixed values (strings, ints, floats, nil, symbols) go through shellescape 12.0x faster. That's Rust on 4 cores against Ruby on one thread, so it's the "hand the whole loop to Rust" number, not a like-for-like one.

It doesn't always win, and it says so. On C# Protobuf's tiny size functions it measured 0.03x, because each call into Rust costs more than the work itself, and bench said "do not ship this unit". Knowing which units to leave alone matters as much as the speedups.

Repo: https://github.com/erkamyaman/rust-anything

What would you want it to port next?

1 Upvotes

0 comments sorted by