rust-anything vs fast-anything: Full Rust Rewrites vs. Hot-Path FFI With AI Coding Agents

Compare rust-anything and fast-anything for Claude Code Rust migrations: FFI overhead traps, verified benchmarks, CLI setups, and when to lift vs. patch.

Deven Rathore 12 min read
On November 29, 2026, two open-source Rust porting tools sit side by side on GitHub Trending: [erkamyaman/rust-anything](https://github.com/erkamyaman/rust-anything) at 11,269 stars and [EL4CTEO/fast-anything](https://github.com/EL4CTEO/fast-anything) at 4,769 stars. Both hook into AI coding agents like Claude Code and Codex to translate slow code from Python, JavaScript/TypeScript, Go, Ruby, Java, and other runtimes into Rust. Both rely on live execution traces to stop agents from hallucinating subtle regressions. Yet the **rust-anything vs fast-anything** debate is not a feature comparison between two clones. It is a clash between two opposing systems architectures: lifting an entire application off its host runtime into a standalone Rust binary versus keeping your host codebase intact and replacing only the hottest 5% of pure functions behind a C FFI bridge. Picking the wrong one either burns weeks migrating glue code that was never slow, or traps your hot path inside a serialization bottleneck that runs slower than native Python. ## Two Viral Philosophies for Agent-Driven Rust Porting Anyone who has opened an LLM chat window and typed "rewrite this service in Rust" already knows how that ends. The generated code compiles after three rounds of borrow-checker fixes, passes the handful of unit tests you remembered to include, and then quietly corrupts production traffic because of an undocumented coercion quirk, a trailing newline difference, or a floating-point edge case nobody wrote a spec for. Both tools fix the same core flaw in an AI coding agent Rust migration: they replace prompt-driven guesswork with recorded behavioral gating. Instead of trusting an agent to infer intent from source code alone, each tool runs the existing program, captures real inputs and outputs, and refuses to accept a Rust port until the new code reproduces those observed behaviors. Where they diverge is the end state: - **rust-anything** treats the host runtime as temporary scaffolding. Its goal is incremental, piece-by-piece migration across a codebase until the original interpreter or VM disappears completely. You ship a single Rust binary with zero Node.js or Python startup overhead. - **fast-anything** treats the host runtime as permanent. Teams choose Python for its libraries and iteration speed ([there are plenty of reasons Python stays dominant](/top-9-reasons-why-python-is-so-popular/)), not because they want to maintain a Rust web framework. `fast-anything` profiles the running app, targets only the slowest 5% of pure functions, compiles Rust replacements behind a C FFI bridge, and leaves the other 95% of your codebase untouched. That single design choice dictates everything downstream: which languages and code patterns work, how bindings are generated, and where performance actually improves. ## How Their Verification Loops and FFI Bridges Actually Differ Under the hood, the two tools run very different pipelines from trace capture to deployment. ### rust-anything: Record, Front-Door, Wire, Lift `rust-anything` organizes migrations into four explicit stages: **record -> front-door -> wire -> lift**. First, it records real executions of your application—CLI invocations, HTTP requests, or function-level runs—to build a golden replay corpus. Next, it wraps the entry point behind a front-door harness so behavior can be checked end-to-end. From there, it wires individual modules into Rust using idiomatic native bindings rather than a lowest-common-denominator shim: **PyO3** for Python, **napi-rs** for Node.js, **cgo** for Go, and **JNI** for Java. During migration, shadow mode and behavioral gates compare the Rust implementation against recorded outputs before promoting a module. Once enough of the call graph lives in Rust, the final **lift** phase drops the host runtime altogether. It supports 11 languages—TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, and PowerShell—and handles stateful modules, CLI tools, and servers rather than restricting you to pure math helpers. ### fast-anything: Profile First, Isolate Pure Functions, Gate Over C FFI The `fast-anything` Rust CLI skips migration architecture completely and starts with a profiler. You point it at a real command across Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, or C#, and it measures where CPU time actually goes. Once it identifies the slowest 5% of pure functions, it records up to **500 real calls** from your execution trace and automatically injects synthetic edge cases—`NaN`, infinity, and empty inputs—to flush out boundary bugs. The coding agent then generates a Rust implementation exposed through a **C FFI serialization bridge**. Before patching your call site, `fast-anything` replays all recorded calls plus the injected edge cases across the bridge. If a single return value diverges, the agent iterates until the gate passes. | Dimension | `erkamyaman/rust-anything` | `EL4CTEO/fast-anything` | | --- | --- | --- | | **Primary goal** | Incremental whole-app Rust migration | Keep host stack; accelerate slowest 5% pure functions | | **Workflow loop** | `record -> front-door -> wire -> lift` | Profile -> capture calls + edge cases -> port -> verify | | **Supported languages** | 11 languages (TS, JS, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell) | Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C# | | **Binding / FFI layer** | Idiomatic native bindings (PyO3, napi-rs, cgo, JNI), then standalone binary | C FFI serialization bridge | | **Verification gate** | Shadow mode and full recorded run replay (byte-for-byte / HTTP cases) | Up to 500 real recorded calls + injected `NaN`, infinity, empty inputs | | **Code constraints** | Supports stateful modules, CLIs, and HTTP services | Requires deterministic pure functions (no hidden I/O or mutation) | | **Rollback safety** | Shadow mode / staged wiring before deleting host runtime | Localized call-site swap; host code remains intact | ## Hands-On Setup: Running Both Tools With Claude Code Both projects treat Claude Code as a first-class driver, but their installation and agent wiring differ slightly. Here is the working CLI path for both if you want to rewrite Python to Rust with Claude Code on an existing script. ### Setting Up rust-anything With Claude Code For a quick `rust-anything` tutorial, install the binary via Cargo (or globally through npm), wire its MCP server and agent skills into your coding agent, verify your local toolchains, and launch a traced run: ```bash # Install via Cargo cargo install rust-anything # Alternative npm install # npm install -g rust-anything # Wire MCP integration and agent skills for Claude Code rust-anything setup # Verify Rust toolchain, language runtimes, and binding prerequisites rust-anything doctor # Start a traced migration workflow against an existing Python app rust-anything go -- python3 app.py ``` Running `rust-anything doctor` before touching a repository saves real time—missing Python headers or mismatched native binding toolchains show up immediately instead of halfway through an agent session. Because the CLI wraps arbitrary shell entry points after `--`, it slots cleanly into existing automation and [shell-driven build or test pipelines](/bash-scripting/). ### Setting Up fast-anything With Claude Code `fast-anything` ships on npm as [@el4cteo/fast-anything](https://www.npmjs.com/package/@el4cteo/fast-anything). You can install it globally or invoke it on demand with `npx`, install the agent skill for your coding agent, and launch the profiler-to-port loop directly against Claude Code: ```bash # Global install npm i -g @el4cteo/fast-anything # Or run without installing globally # npx @el4cteo/fast-anything # Profile the app and port hot pure functions using Claude Code fast-anything go --agent claude -- python app.py ``` ### Walking Through a Slow Data-Processing Loop Suppose `app.py` reads a batch of product titles and runs a slow pairwise similarity pass to cluster near-duplicates: ```python def normalize_and_dedup(records: list[str], threshold: float) -> list[str]: # Pure function: deterministic input -> output, heavy O(n^2) CPU work kept: list[str] = [] for item in records: tokens = set(item.lower().split()) if not any(_jaccard(tokens, set(k.lower().split())) >= threshold for k in kept): kept.append(item) return kept def _jaccard(a: set[str], b: set[str]) -> float: if not a and not b: return 1.0 return len(a & b) / len(a | b) ``` Watch what happens when you point each tool at this workload: 1. **With `fast-anything`**: the profiler flags `normalize_and_dedup` (and `_jaccard`) as the CPU hotspot. `fast-anything` captures up to 500 real invocations from your run alongside edge cases like empty lists and extreme float thresholds, invokes Claude Code to emit a Rust crate behind a C FFI bridge, verifies every output matches, and swaps the Python call site to the compiled library. Your CLI argument parser, file loader, and downstream database writes remain standard Python. 2. **With `rust-anything`**: the harness records full inputs and outputs at the application boundary. Claude Code can first wire the Python deduplication module into Rust through PyO3 under shadow verification, then keep lifting the file I/O and CLI scaffolding in subsequent passes until `app.py` compiles down to a single native binary. ## What the Benchmarks Show — and Where the FFI Overhead Trap Bites The published numbers from both projects show why neither approach is hype—and why they solve completely different bottlenecks. On the [rust-anything benchmarks site](https://rustanything.ai), two full-application lifts stand out: - **Prettier CLI port**: Matched **17,224 of 17,224** recorded runs byte-for-byte. Formatting 2,360 JavaScript and TypeScript files dropped from **128.6s to 6.9s (~19x faster)**, while 6,305 Markdown files dropped from **352s to 22.5s (~15.6x faster)**. - **`json-server` full lift**: Verified across **514 of 514** recorded HTTP cases. Dropping the Node.js runtime cut idle memory from **74 MB to 3.5 MB** and slashed startup latency from **79–85 ms down to 8–10 ms**, compiling the entire server into a **5.3 MB binary**. Meanwhile, [fast-anything's fuzzy-dedup benchmark](https://github.com/EL4CTEO/fast-anything) posted a **116x–145x speedup**, collapsing runtime from **4.47 seconds down to 31 milliseconds** without rewriting the surrounding application. Looking at those numbers side by side reveals the exact architectural boundary between the two tools. No hot-path FFI patch can ever turn a 74 MB Node.js process into a 3.5 MB binary—even if you speed up your hottest handler by 100x, you still pay the host runtime's memory floor and cold-start latency (the same runtime overhead that drives teams to evaluate [alternative JS runtimes and Bun web frameworks](/exploring-the-top-web-frameworks-built-using-bun/)). Conversely, if your Python batch job spends 4.47 seconds inside one deduplication kernel and 40 milliseconds everywhere else, lifting the entire codebase into Rust buys you almost nothing over patching that single function. ### The FFI Overhead Trap There is a catch in `fast-anything`'s model that bites engineers who treat it like a magic wand: **chatty functions lose across a C FFI boundary**. In the example above, porting `normalize_and_dedup`—which crosses the FFI boundary *once* per batch and loops millions of times inside Rust—delivers massive wins. Porting `_jaccard` instead—which gets called hundreds of thousands of times from a Python `for` loop—does the opposite. Every single invocation has to serialize host data structures across C FFI, cross the language boundary, allocate or unpack the inputs in Rust, and marshal the return value back. When the per-call compute work is smaller than the serialization tax, your "Rust-accelerated" function finishes slower than the original interpreted Python or V8 JIT code. With `fast-anything`, you always want the loop *inside* the ported Rust function, not wrapping it in the host language. ### Where Pure-Function Constraints Break Down `fast-anything` also hits a hard wall on real-world enterprise code that mixes compute with state: - **Class methods mutating `self`**: If a hot method reads and mutates five attributes on an object instance, trace replay cannot isolate it cleanly without serializing object state. - **Hidden I/O and logging**: Functions that quietly touch a local cache file, emit metrics, or query an environment variable break deterministic verification. - **Non-deterministic logic**: Calls to system clocks, unordered iteration side effects, or unseeded RNGs fail replay gates. To use `fast-anything` on those paths, you have to refactor the compute core into an explicit pure function first—passing state in as plain data and returning transformed values out. If the bottleneck is deeply braided into stateful orchestration or HTTP lifecycle handling, `rust-anything`'s module-level wiring and full-app replay are a much cleaner fit. ## Decision Guide: When to Lift the Whole App vs. Patch the Hot 5% You do not need to guess which tool fits your repository. Look at what is actually hurting in production: - **Choose `fast-anything`** when you own a large Python, TypeScript, or Ruby codebase you want to keep, and profiling proves that CPU time is concentrated in self-contained compute loops—parsing, fuzzy deduplication, scoring, ranking, geometry, or numerical transforms. You get 100x-class kernel speedups without retraining the team or rewriting your web framework. - **Choose `rust-anything`** when the host runtime itself is the bottleneck. That includes CLI tools where 80 ms startup latency feels sluggish, sidecars or microservices where 74 MB idle RAM per container multiplies across hundreds of pods, or developer tools where shipping a 5.3 MB single binary eliminates "install Python/Node first" support tickets. - **Refactor before profiling** if your hot path is a chatty helper called inside a host loop or a stateful class method. Hoist the loop into a batch pure function before handing it to `fast-anything`, or commit to `rust-anything`'s staged lifting path. ### Production Readiness Checklist Before Shipping Agent-Ported Rust Passing 500 recorded calls or a golden replay suite gets you past the prototype stage, not automatically to production. Before merging agent-generated Rust into a critical path, enforce three guardrails: 1. **Lock the replay corpus into CI**: Treat recorded traces as permanent regression tests. Every future PR touching either the host wrapper or the Rust crate should re-run the behavioral gate automatically. 2. **Keep a runtime fallback toggle**: Put new Rust paths behind an environment flag or shadow-mode switch during initial rollout. If an unseen production payload triggers a mismatch that never appeared in the captured trace, you want an instant toggle back to the original implementation—not an emergency rollback build. 3. **Audit every `unsafe` block and FFI boundary by hand**: AI coding agents optimize to turn red tests green. They are much less reliable at catching panics unwinding across C FFI, subtle memory leaks across allocator boundaries, or lifetime bugs in native bindings. Require a human engineer to review every `unsafe` block and FFI marshaling shim before shipping. Both `rust-anything` and `fast-anything` prove that trace-gated agents have crossed the line from demo to practical engineering workflow. The difference between a 19x CLI speedup and a broken, serialization-bound patch comes down to whether you match the tool to the real bottleneck: delete the runtime with `rust-anything`, or isolate the hot math with `fast-anything`.
Deven Rathore

Engineering workflows, AI coding tools, and developer guides published on DuneBook.

Technical Documentaries · October 29, 2024

The Untold Story of Stack Overflow

Before Stack Overflow, programmers always needed a place to ask questions and find help—whether it was old forums, chat rooms, or paid sites. For years,…

Web Development · July 14, 2024

Top 5 Github Repos to master Next.js

In this video, we’re going to explore the 5 GitHub Repos +bonus repo to master Nextjs, that will not only teach you Nextjs but also…