====== Vibe Porting: Using AI Agents to Port Code Between Languages ====== **Vibe porting** (also called **vibespiling**) is the practice of using AI coding agents to port software from one programming language to another. It is a practical pattern where AI excels because the existing codebase serves as both the specification and the test oracle -- the agent knows exactly what the code should do and can verify its output against the original implementation. ===== Origin of the Term ===== The term **vibespiling** was coined by Emil Stenström, inspired by Simon Willison's coding agent port of JustHTML from Python to JavaScript. Willison subsequently adopted the term **vibe porting** to describe this broader pattern((Source: [[https://simonwillison.net/2025/Dec/17/vibespiling/|Simon Willison - AoAH Day 15: Vibespiling]])). Willison has used the term in his blogmarks to describe cases where existing test suites enable AI-driven rewrites((Source: [[https://simonwillison.net/b/9400|Simon Willison - Blogmark on JSONata vibe porting]])). ===== Why AI Excels at Porting ===== Code porting is uniquely well-suited to AI agents for several reasons: * **Existing code as specification**: The source code defines exactly what the target implementation should do, eliminating ambiguity * **Test suites as oracle**: Comprehensive test suites provide an objective measure of correctness that the agent can run iteratively * **Mechanical translation**: Much of porting involves translating idioms and patterns between languages -- exactly the kind of pattern-matching LLMs handle well * **Iterative verification**: Coding agents can execute the ported code, run tests, observe failures, and iterate until all tests pass ===== Case Studies ===== ==== JustHTML: Python to JavaScript ==== Simon Willison ported Emil Stenström's JustHTML -- a standards-compliant HTML5 parser written in pure Python using coding agents -- from Python to JavaScript using Codex CLI and GPT-5.2. The result was ''simonw/justjshtml'', a dependency-free HTML5 parsing library that passes 9,200 tests from the html5lib-tests suite((Source: [[https://simonwillison.net/2025/Dec/15/porting-justhtml/|Simon Willison - I ported JustHTML from Python to JavaScript with Codex CLI and GPT-5.2 in 4.5 hours]])). Key details: * Two initial prompts and a few follow-ups * GPT-5.2 ran uninterrupted for several hours * Burned through 1.4M input tokens, 97M cached input tokens, and 625K output tokens * Produced 9,000 lines of tested JavaScript across 43 commits * Total elapsed time: approximately 4 hours, during which Willison bought and decorated a Christmas tree ==== html5rw: Python to OCaml ==== Anil Madhavapeddy, inspired by the JustHTML port, built ''html5rw'' -- an HTML5 parser in OCaml that passes the same html5lib-tests suite. This was part of his "Advent of Agentic Humps" project, building a new useful OCaml library every day in December 2025((Source: [[https://simonwillison.net/2025/Dec/17/vibespiling/|Simon Willison - AoAH Day 15: Vibespiling]])). ==== JSONata: JavaScript to Go ($500K/year savings) ==== Reco, a cybersecurity company, used AI to rewrite the JSONata JSON expression language from JavaScript to Go in 7 hours for $400 in Claude tokens. Willison described this as "another case study of vibe porting"((Source: [[https://simonwillison.net/b/9400|Simon Willison - Blogmark on JSONata vibe porting]])). The background: Reco's pipeline runs in Go, but JSONata's reference implementation is JavaScript. For years they ran a fleet of Node.js pods on Kubernetes that their Go services called over RPC, costing approximately $300K/year in compute with 150-microsecond RPC latency on every evaluation((Source: [[https://www.reco.ai/blog/we-rewrote-jsonata-with-ai|Reco - We Rewrote JSONata with AI in a Day, Saved $500K/Year]])). The approach: * Ported the official jsonata-js test suite (1,778 tests) to Go first * Used AI to implement the evaluator until all tests passed * Ran a shadow deployment for a week comparing old and new implementations in parallel * Result: 1,000x faster performance, $500K/year in total savings((Source: [[https://www.reco.ai/blog/we-rewrote-jsonata-with-ai|Reco - We Rewrote JSONata with AI in a Day, Saved $500K/Year]])) The enabling factor, as with all vibe porting projects, was the existing comprehensive test suite. ===== Patterns for Success ===== * **Port the tests first**: Convert the test suite to the target language before attempting the implementation * **Use comprehensive test suites**: The quality of the port depends directly on test coverage * **Shadow deployment**: Run old and new implementations in parallel to catch behavioral differences not covered by tests * **Iterative agent loops**: Let the coding agent run tests, observe failures, and iterate autonomously * **Credit original authors**: Willison and Madhavapeddy both credited Emil Stenström in their licenses, acknowledging the architectural logic came from the original ===== Ethical Considerations ===== Madhavapeddy raised important questions about the copyright and ethics of vibespiling: "I am also extremely uncertain about ever releasing this library to the central opam repository, especially as there are excellent HTML5 parsers already available. Whether or not this agentic code is better or not is a moot point if releasing it drives away the human maintainers who are the source of creativity in the code!"((Source: [[https://simonwillison.net/2025/Dec/17/vibespiling/|Simon Willison - AoAH Day 15: Vibespiling]])) ===== See Also ===== * [[vibe_coding]] * [[agentic_coding]] * [[code_generation_agents]] ===== References =====