The promise is compelling: point an AI at your legacy PHP codebase and let it translate everything to Rust, Go, or TypeScript overnight. No rewrite sprints. No hiring surge. Just automated, deterministic migration.
We tested that promise empirically. The results are definitive, and they matter for anyone evaluating AI-assisted modernization strategies.
The Hypothesis
Fully autonomous AI-driven code translation will fail at enterprise scale due to compound error probability. Each translation unit introduces a non-zero error rate, and as codebase size grows, the probability of a clean translation approaches zero.
The Experiment
We designed a controlled study using Claude Sonnet 4 via the Anthropic API, translating production PHP code to Rust across three scale tiers:
- 100+ LOC — function-level translation units
- 1,000+ LOC — module-level translation with cross-file dependencies
- 5,380 LOC — full application translation as a single unit
The question was never whether AI can translate code — it clearly can. The question is whether it can do so autonomously, at scale, without human intervention at every stage.
The Results
At 100+ LOC, compilation failures emerged consistently. The AI produced syntactically plausible Rust that failed to compile due to lifetime annotations, borrow checker violations, and type system mismatches that don't exist in PHP's dynamic type model.
At 1,000+ LOC, architectural breakdown became the dominant failure mode. The AI lost coherence across module boundaries, producing inconsistent interfaces and duplicated abstractions.
At 5,380 LOC, the translation hit token limits before producing usable output — a fundamental constraint, not an engineering problem to be solved with better prompting.
What This Means
Autonomous translation is not a scaling problem that improves with better models. It's a mathematical reality: compound error probability makes fully autonomous migration unviable at enterprise scale. The cost of the experiment was negligible. The value: definitive empirical grounding for a previously theoretical argument.
The practical path forward is AI-assisted migration — human-guided, iterative, with the AI handling translation of well-bounded units while engineers manage architecture, integration, and verification.
Implications for Your Modernization Strategy
If a vendor is promising fully autonomous code migration, ask them to demonstrate it on a codebase above 1,000 LOC with cross-module dependencies. The compound error rate will speak for itself.
The right approach treats AI as a powerful accelerator within a human-directed process, not as a replacement for engineering judgment.