PromptZone - Leading AI Community for Prompt Engineering and AI Enthusiasts

Tara Abbott
Tara Abbott

Posted on

AI Rewrites PHP in Rust, Passes 17% Tests

A developer with no Rust experience used AI to rewrite portions of the PHP engine in Rust, reaching 17% pass rate on PHP-src tests while successfully rendering a WordPress site. The project first appeared in a Hacker News thread that drew 12 points and 9 comments.

What the Experiment Produced

The resulting Rust codebase implements core PHP execution paths. It handles enough of the language to boot and display a standard WordPress installation. The author relied entirely on LLM-generated code, iterating through prompts rather than manual Rust coding.

Test Results and Coverage

The port passes 17% of the official PHP-src test suite. This figure reflects automated validation against the reference implementation rather than hand-written unit tests. WordPress rendering confirms basic compatibility with real-world PHP applications that depend on output buffering, variable handling, and include mechanics.

How the AI-Driven Port Was Built

The workflow started with broad prompts describing PHP internals, followed by targeted fixes for compilation errors and test failures. Each iteration fed compiler output and test logs back into the model. No manual Rust syntax was written by the developer.

Tradeoffs Observed

  • Speed of initial port: Weeks of calendar time compressed into days of prompting.
  • Correctness ceiling: 17% test coverage leaves most edge cases unaddressed.
  • Maintenance burden: Generated code requires human review for safety and performance.
  • Debugging difficulty: Rust borrow-checker errors appear without clear mapping to original PHP semantics.

Comparison With Traditional Rewrites

Manual ports of language runtimes typically require teams and years. Existing efforts such as the original PHP implementation or experimental runtimes like HipHop PHP focused on full fidelity from the start. This AI-assisted attempt trades completeness for rapid prototyping.

Aspect AI-Assisted Rust Port Traditional Manual Port
Developer Rust skill None Expert level
Time to first run Days Months to years
Test coverage 17% 80%+ targeted
Production readiness Experimental Production in some cases

Who Should Attempt Similar Projects

Teams exploring language interoperability or legacy modernization can use this pattern for feasibility checks. Researchers studying LLM code generation limits will find the 17% result a useful baseline. Production teams needing full compatibility should continue with conventional engineering instead.

Practical Next Steps

Clone the repository linked in the original post and run the existing test harness. Extend coverage by prompting the model with specific failing tests. Measure both execution speed and memory usage against stock PHP on identical workloads.

Bottom line: The project demonstrates that current LLMs can produce runnable Rust implementations of complex C codebases with zero prior language expertise, though full compatibility remains distant.

Early community discussion on Hacker News focused on whether incremental test-driven prompting can scale beyond 17% coverage or if architectural mismatches will cap progress.

Top comments (0)