Program Skeletons for Automated Program Translation
arXiv:2504.07483 · doi:10.1145/3729287
Abstract
Translating software between programming languages is a challenging task, for which automated techniques have been elusive and hard to scale up to larger programs. A key difficulty in cross-language translation is that one has to re-express the intended behavior of the source program into idiomatic constructs of a different target language. This task needs abstracting away from the source language-specific details, while keeping the overall functionality the same. In this work, we propose a novel and systematic approach for making such translation amenable to automation based on a framework we call program skeletons. A program skeleton retains the high-level structure of the source program by abstracting away and effectively summarizing lower-level concrete code fragments, which can be mechanically translated to the target programming language. A skeleton, by design, permits many different ways of filling in the concrete implementation for fragments, which can work in conjunction with existing data-driven code synthesizers. Most importantly, skeletons can conceptually enable sound decomposition, i.e., if each individual fragment is correctly translated, taken together with the mechanically translated skeleton, the final translated program is deemed to be correct as a whole. We present a prototype system called Skel embodying the idea of skeleton-based translation from Python to JavaScript. Our results show promising scalability compared to prior works. For 9 real-world Python programs, some with more than about 1k lines of code, 95% of their code fragments can be automatically translated, while about 5% require manual effort. All the final translations are correct with respect to whole-program test suites.
arXiv commentAccepted by PLDI 2025 (46th ACM SIGPLAN Conference on Programming Language Design and Implementation)
References in corpus (17)
- PaLM: Scaling Language Modeling with Pathways
- Code Llama: Open Foundation Models for Code
- CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
- Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code
- Perfection Not Required? Human-AI Partnerships in Code Translation
- StarCoder 2 and The Stack v2: The Next Generation
- Lost in the Middle: How Language Models Use Long Contexts
- DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence
- A Survey of Large Language Models for Code: Evolution, Benchmarking, and Future Trends
- AlphaTrans: A Neuro-Symbolic Compositional Approach for Repository-Level Code Translation and Validation
- Can Large Language Models Write Good Property-Based Tests?
- Towards Translating Real-World Code with LLMs: A Study of Translating to Rust
- Rectifier: Code Translation with Corrector via LLMs
- Automatic Inference of Specifications in the K Framework
- SteloCoder: a Decoder-Only LLM for Multi-Language to Python Code Translation
- VERT: Verified Equivalent Rust Transpilation with Large Language Models as Few-Shot Learners
- Skeleton-Guided-Translation: A Benchmarking Framework for Code Repository Translation with Fine-Grained Quality Evaluation