Rewrite Code with Evidence, Not Confidence: Inside rust-anything
First, apologies to everyone for the long silence; I've been in deep cultivation for a while. Today I want to talk about what I've been working on. Let's start with rust-anything. I'm currently the second-in-command on the project 😄. I'm not here to brag, but to share my thoughts on what has changed and what hasn't in AI-era software engineering. My view: Past software engineering relied on experience to guarantee quality; future software engineering will increasingly rely on evidence to guarantee change.
Opening | If AI can write hundreds of thousands of lines of code a day, does refactoring get easier?
Let me ask a question:
If AI could one day generate hundreds of thousands of lines of code per day, would software refactoring become simpler?
My answer is: No. And I'll put the core conclusion right here:
The biggest problem in AI Coding is not generation capability, but verification capability.
Because the truly hard things in software engineering have never been about "writing code" or "generating code," but:
- How to understand an old system that has run for many years;
- How to guarantee that the new system behaves identically to the old one;
- How to safely migrate piece by piece;
- How to verify that every change is correct.
This is also the biggest lesson I've taken from participating in rust-anything.
This article doesn't intend to introduce a Rust open-source project. I want to break it apart and explain why it's designed this way, and what it made me reconsider.
Part 1 | The Problem: Why Rewrites Always Fail
1.1 The Biggest Contradiction in the Software World
Technology keeps advancing: new languages, new frameworks, new architectures appear endlessly.
But the core systems of many enterprises still run on Java, C++, Python, JavaScript, and PHP.
Why not switch?
Rewriting a system is easy; guaranteeing a system runs stably for ten years is hard.
What's embedded in an old system is not just code, but the pitfalls encountered over a decade, the bugs fixed, the strange upstream and downstream integrations. These things are worth more than the code itself, and far harder to migrate.
1.2 Why Rewrites Often Fail
The traditional approach to rewriting is intuitive:
It looks clear, but the problems hide in every gap between steps:
Behavior is unknowable. Old systems are full of implicit logic: boundary conditions, historical compatibility, exceptional flows. Not in the documentation, not in the comments, often known only to the person who wrote it, and even they may have forgotten.
Tests can't cover the real world. For a system that has run for years, the true requirements aren't in the requirements document, but in live traffic. No matter how complete the test cases, they are just a sampling of the real world.
Replacement risk is enormous. A one-shot switch affects users, data, and the entire business process. If something goes wrong, the cost of rollback is often higher than expected.
So a rewrite fails, usually not because the new code is poorly written, but because:
There is no way to prove the new system is consistent with the old system.
1.3 When AI Arrives, the Problem Just Changes Shape
AI Coding has dramatically reduced the cost of code generation. Translating a piece of logic into another language no longer takes weeks.
But this pushes the problem to the other end. Back to the opening line: it's not generation capability, but verification capability.
When generation becomes cheap, what's scarce changes. The bottleneck is no longer "who writes it," but "dare we use it?"
(Remember that line; we'll see it again later.)
Part 2 | Design: How rust-anything Solves It
2.1 A One-Sentence Introduction
Convert your application to Rust piece by piece, and verify each piece against the "recorded real behavior" of the original system.
There's a line in its README I really like: It doesn't translate code; it proves the rewrite is correct.
2.2 Why Is It Called rust-anything?
When you first see the name, you might be puzzled.
Why not rust-migrate? Why not rust-port?
In my view, the key is Anything.
It doesn't mean "migrate the entire project to Rust," but: any single thing can be migrated little by little.
A function, a module, a CLI, a service. You don't need permission for a "full rewrite," and you don't need to bet the whole system at once. You can pick the slowest function, move it out, verify it passes, then decide on the next one.
This is a small but critical shift: the unit of migration changes from "system" to "any small piece."
The README even has a pragmatic reminder: if every small function makes a separate cross-language call to Rust, it can be slower than JIT. So the focus isn't "migrate more," but first find the piece truly worth migrating.
2.3 Why Didn't They Build a "Code Converter"?
Many people's first reaction is: since AI is so good at writing code, why not just build an automatic converter?
That's exactly the most important design decision of the whole project.
rust-anything's stance is clear: division of labor.
- Generating code becomes cheaper and less scarce every day; let AI (or yourself) handle it.
- Providing evidence that the generated code is correct is the hard part, and that's what rust-anything actually does.
If it tried to do the conversion itself, it would have to take responsibility for whether the conversion is correct, and that's a bottomless pit. By separating "generation" and "verification," both sides can improve independently: the stronger the AI, the faster the generation; the stricter the verification, the more stable the release.
I think this is the project's biggest idea:
AI handles Generate; rust-anything handles Evidence.
2.4 How Does It Work?
The pipeline below is the skeleton of the whole project:
Rather than listing commands, let me answer a more interesting question: why does each step have to exist?
Why Profile? — Measure First, Then Act
Before a rewrite, the first question isn't "how to write," but "where to write it."
Choosing targets by gut feeling often leads to picking the wrong thing: the place you think is slow isn't, and the truly slow spot gets ignored. profile exists to make the decision of "what to migrate" data-driven, avoiding effort with no payoff.
Why Bridge? — Because Systems Can't Stop
An old system can't be replaced overnight. So the old and new worlds must be able to coexist.
bridge solves that: it builds a bridge between the old and new languages (under the hood using libraries like napi-rs, PyO3, wasm-bindgen to pass calls), letting a Rust function stand directly in the position of the original function, while the rest of the system stays untouched.
Without this bridge, migration can only be "all or nothing," and we're back to the old rewrite path.
Why Record? — Let the Old System Write Its Own Spec
This is, in my view, the project's most core design.
To prove the new code is consistent with the old, you need a "reference answer." The traditional approach relies on documentation, requirements, and people thinking about "what it should be." But as said earlier, those are often incomplete.
record takes another path: stop guessing; let the old system act it out. It records the real input/output pairs of the migrated unit during actual runtime, forming a behavioral record.
The real behavior of the old system is itself the most authoritative specification.
That's also why I don't think it's just logging: what it records is evidence that can be replayed and compared.
Why Diff? — Turn "Feels Wrong" into "Know Where It's Wrong"
With recordings in hand, you can run the same inputs against the Rust version and compare line by line.
diff has a strict requirement: every single recorded case must match. It turns the vague judgment of "seems about right" into a question with a definite answer, and when something doesn't match, it can tell you exactly which case and where the difference is.
Why Bench? — Rust Doesn't Naturally Make Everything Faster
Many people migrate to Rust for performance. But "switching to Rust makes it faster" is an impression, not a fact.
bench exists to let data answer whether it's worth it. If a migrated unit isn't faster in Rust, the migration is meaningless. Performance gains also need to be proven.
Why Is Gate Last? — "Done" Needs to Be Defined
Every previous step produces evidence: behavioral equivalence, performance targets. gate does the final thing: synthesizes that evidence into a clear verdict.
Its significance is that "done" stops being a subjective feeling and becomes an executable gate: pass and it's done, fail and you go back.
It's placed last because it depends on the results of all previous steps; it's a decision point, not an execution point.
Why Must Disable Exist? — Shipping Should Not Be a One-Way Door
This last command is the easiest to overlook, yet it embodies the most mature engineering mindset.
disable lets you revert to the original version, byte-identical.
That means every migration has a way back. You can move forward boldly because you know you can always retreat. If shipping is irreversible, every migration becomes a gamble.
A Real Example
The project demonstrated a case in version 2.0: rewriting Prettier in Rust, about 19× faster. Of 17,224 recorded runs, 15,861 were executed entirely by Rust, and every output was byte-identical to the original.
This example best captures the project's ethos: not "I think it's faster," but "I have data, a comparison, and proof."
Part 3 | Thinking: Why This Design
3.1 The Real Change in AI Coding
When people talk about AI Coding, the first reaction is often: "Programmers will write less and less code."
I think that's only the surface.
The real change in AI Coding is not that programmers write less code, but that software for the first time has the capability of "continuous verification."
In the past, verification was expensive, low-frequency, and human-dependent: run tests before release, debug if something breaks.
When generation becomes cheap and changes become frequent, verification must become continuous, automatic, and evidence-based. Otherwise, the speed of change will far outpace our speed of understanding it.
3.2 Software Verification Runtime
If you abstract the steps of rust-anything, you'll see the core isn't actually Rust:
It's a runtime mechanism for "how to make change verifiable."
If Agents have an Agent Runtime, and Memory has a Memory Runtime, then shouldn't "making change verifiable" also have its own Runtime?
I'd call it:
Software Verification Runtime (软件验证运行时)
Rust is just the target it currently serves. Swap the target language, swap the source of change, and this skeleton still holds.
3.3 Where the Engineer's Focus Is Moving
If generation is cheap and verification is scarce, the value of engineers shifts accordingly.
In the past, an engineer's core output was code.
In the future, what matters more will be:
- Defining the goal: what do we want, and what does "correct" mean;
- Designing the verification system: what evidence proves it's correct;
- Managing AI Agents: keeping them working efficiently within controlled boundaries.
The gate command impressed me because it turns "what done means" into an executable line. That's a very concrete kind of engineering thinking: turn judgment into mechanism.
Part 4 | An Unexpected Discovery
4.1 Wait... Does This Look Familiar?
Writing this, I stopped.
Looking back at what I've described:
- Record: record real behavior;
- Replay: replay history;
- Diff / Evaluate: judge whether a change is good or bad;
- Gate: decide whether to ship;
- Disable: roll back if something goes wrong.
Wait... haven't I seen these somewhere?
When I worked on Agent Runtime, wasn't I solving the same problems?
4.2 Two Seemingly Unrelated Fields, the Same Question
| rust-anything (code migration) | Agent Runtime (agent systems) |
|---|---|
| Record: capture original input/output | Record Prompt, Tool Call, Memory, Output |
| Replay + Diff: replay and compare | Reproduce historical tasks, compare old vs. new performance |
| Bench: measure benefit | Evaluation: judge whether the agent truly improved |
| Gate: only release on pass | Control whether a new agent version can ship |
| Disable: one-click rollback | Roll back to a previous stable version on failures |
They're facing the same problem:
After a system changes, how do I know it didn't get worse?
Migrating code works that way. Upgrading a model works that way. Changing a Prompt works that way. Redesigning an agent workflow works the same way.
4.3 What AI Systems Need Next
So I increasingly believe:
The future of AI systems isn't just bigger models.
It also needs a stronger Runtime: one that can record, replay, evaluate, and gate.
The model sets the upper bound of capability; the Runtime sets the lower bound of usability.
That's the biggest insight rust-anything gave me, beyond Rust itself.
Part 5 | Practice: Why I Keep Participating in This Project
I started in this repo from a single error line — 4 lines of Rust for 1 lines of TypeScript/JavaScript — and worked up to implementing the app record --ready readiness probe, the bridge alias resolution index, Java/Kotlin plugin recognition of "hidden state," and HTTP server lifecycle testing. Now with nearly a hundred merges, I rank second in Contributors. The reason I stay is that every step here requires turning "it got better" into measurable evidence.
Summary:
In the past, software engineering solved: how to develop quickly.
In the future, software engineering needs to solve: how to make AI reliably produce change.
Code will become easier and easier to obtain, and "trustworthiness" will become more and more precious.
The software engineering of the future won't compare who writes faster, but who can prove that "this change deserves to be trusted."
Past software engineering relied on experience to guarantee quality; future software engineering will increasingly rely on evidence to guarantee change.
So, rewriting code no longer relies on "confidence," but on "evidence."
Appendix | Quick Start
If you want to try it yourself:
Installation
cargo install rust-anything # install from crates.io
rust-anything setup # register with Claude Code / Codex / Cursor / Gemini CLI etc.
No Rust environment? JavaScript projects can directly use npm install -g rust-anything; precompiled binaries are also available from GitHub Release (macOS / Linux aarch64 and x86_64, Windows x86_64). Extract and put rust-anything into your PATH.
Simplest usage: one command
rust-anything go --agent claude -- python3 app.py
Full manual pipeline
# What's hottest? Who's calling it? For mixed-language repos (e.g., a Python project with a package.json)
# explicitly specify the language: rust-anything profile . --lang python -- node bench.mjs
rust-anything profile . -- node bench.mjs
# Generate bridging
rust-anything bridge . src/fuzzy.ts
# Add --batch when profile recommends; syntax is `functionName:paramName`:
# e.g., --batch fuzzyScore:text moves fuzzyScore's text parameter to Rust for batch scoring
# Write src/port.rs (yourself or with AI), then:
rust-anything record rust/fuzzy-rs && rust-anything build rust/fuzzy-rs
rust-anything diff rust/fuzzy-rs # every recorded case must match
rust-anything bench rust/fuzzy-rs # is it actually faster?
rust-anything gate rust/fuzzy-rs # pass and it's done
rust-anything report rust/fuzzy-rs # generate REPORT.md to paste into a Pull Request
rust-anything disable rust/fuzzy-rs # revert to the original version at any time
Related links
- Project homepage: https://github.com/erkamyaman/rust-anything
- Documentation: https://rust-anything.com/
- Contributors: https://github.com/erkamyaman/rust-anything/graphs/contributors