Abstract
Large language models (LLMs) show promise in code translation due to their ability to generate idiomatic code. However, a significant limitation when using LLMs for code translation is scalability: existing works have shown a drop in translation success rates for code exceeding around 100 lines. We overcome this limitation by developing a modular approach to translation, where we partition the code into small code fragments which can be translated independently and semantically validated (that is, by checking I/O equivalence). When this approach is applied naively, we discover that LLMs are unreliable when translating features of the source language that do not have a direct mapping to the target language, and that the LLM often gets stuck in repair loops when attempting to fix errors. To address these issues, we introduce two key concepts: (1) feature mapping, which integrates predefined translation rules with LLM-based translation to guide the LLM in navigating subtle language differences and producing semantically accurate code; and (2) type-compatibility, which facilitates localized checks at the function signature level to detect errors early, thereby narrowing the scope of potential repairs. We apply our approach to translating real-world Go codebases to Rust, demonstrating that we can consistently generate reliable Rust translations for projects up to 9,700 lines of code and 780 functions, with an average of 73% of functions successfully validated for I/O equivalence, considerably higher than any existing work.
| Original language | English |
|---|---|
| Title of host publication | Proceedings of the ACM on Programming Languages |
| Subtitle of host publication | Issue PLDI |
| Editors | Michael Hicks |
| Place of Publication | New York |
| Publisher | Association for Computing Machinery |
| Pages | 1616-1641 |
| Number of pages | 26 |
| Volume | 9 |
| DOIs | |
| Publication status | Published - 13 Jun 2025 |
| Event | 46th ACM SIGPLAN Conference on Programming Language Design and Implementation - Westin Josun Seoul, Seoul, Korea, Republic of Duration: 16 Jun 2025 → 20 Jun 2025 https://pldi25.sigplan.org/ |
Publication series
| Name | Proceedings of the ACM on Programming Languages |
|---|---|
| Publisher | Association for Computing Machinery |
| ISSN (Electronic) | 2475-1421 |
Conference
| Conference | 46th ACM SIGPLAN Conference on Programming Language Design and Implementation |
|---|---|
| Abbreviated title | PLDI 2025 |
| Country/Territory | Korea, Republic of |
| City | Seoul |
| Period | 16/06/25 → 20/06/25 |
| Internet address |
Bibliographical note
Publisher Copyright:© 2025 owner/author(s)
Research Groups and Themes
- Programming Languages
Fingerprint
Dive into the research topics of 'Scalable, Validated Code Translation of Entire Projects using Large Language Models'. Together they form a unique fingerprint.Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver