Code translation aims to convert source code from one programming language (PL) to another. Given the promising abilities of LLMs in code synthesis, researchers are exploring their potential to automate code translation. The prerequisite for advancing the state of LLM-based code translation is to understand their promises and limitations over existing techniques. To that end, we present a large-scale empirical study to investigate the ability of general LLMs and code LLMs for code translation across pairs of different languages, including C, C++, Go, Java, and Python. Our study, which involves the translation of 1,700 code samples from three benchmarks and two real-world projects, reveals that LLMs are yet to be reliably used to automate code translation -- with correct translations ranging from 2.1% to 47.3% for the studied LLMs. Further manual investigation of unsuccessful translations identifies 15 categories of translation bugs. We also compare LLM-based code translation with traditional non-LLM-based approaches. Our analysis shows that these two classes of techniques have their own strengths and weaknesses. Finally, insights from our study suggest that providing more context to LLMs during translation can help them produce better results. To that end, we propose a prompt-crafting approach based on the symptoms of erroneous translations; this improves the performance of LLM-based code translation by 5.5% on average. Our study is the first of its kind, in terms of scale and breadth, that provides insights into the current limitations of LLMs in code translation and opportunities for improving them. Our dataset -- consisting of 1,700 code samples in five PLs with 10K+ tests, 43K+ translated code, 1,748 manually labeled bugs, and 1,365 bug-fix pairs -- can help drive research in this area.
We're not able to analyze this paper right now due to high demand.
Please check back later (sorry!).
Generate a detailed summary of this paper with a premium account.
We ran into a problem analyzing this paper.
Upgrading GitHub from Rails 3.2 to 5.2. https://github.blog/2018-09-28-upgrading-github-from-rails-3-2-to-5-2/.
2020a. Supporting Linux kernel development in Rust. https://lwn.net/Articles/829858/.
2020b. Transform monolithic Java applications into microservices with the power of AI. https://developer.ibm.com/tutorials/transform-monolithic-java-applications-into-microservices-with-the-power-of-ai/.
2020c. Will code move on to a language such as Rust? https://www.theregister.com/2020/06/30/hard_to_find_linux_maintainers_says_torvalds/.
GitHub’s Journey from Monolith to Microservices. https://www.infoq.com/articles/github-monolith-microservices/.
Apache Commons CLI. https://commons.apache.org/proper/commons-cli/.
Artifact Website. https://github.com/Intelligent-CAT-Lab/PLTranslationEmpirical.
C to Go Translator. https://github.com/gotranspile/cxgo.
C2Rust Transpiler. https://github.com/immunant/c2rust.
CodeGeeX. https://github.com/THUDM/CodeGeeX/blob/main/tests/test_prompt.txt.
GPT-4 Technical Report. https://cdn.openai.com/papers/gpt-4.pdf.
Hugging Face Open LLM Leaderboard. https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard.
Java 2 CSharp Translator for Eclipse. https://sourceforge.net/projects/j2cstranslator/.
Java to CSharp Converter. https://github.com/paulirwin/JavaToCSharp.
Llama-2. https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/.
pycompile—Compile Python source files. https://docs.python.org/3/library/pycompile.html.
Sharpen - Automated Java-¿C# coversion. https://github.com/mono/sharpen.
TheBloke Airoboros 13B. https://huggingface.co/TheBloke/airoboros-13B-HF.
TheBloke Wizard Vicuna 13B. https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-HF.
TIOBE Index. https://www.tiobe.com/tiobe-index/.