An Extensive Empirical Study on Code Translation Technique
Analyze & explore related research in Conceptio
Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
1
An Extensive Empirical Study on Code Translation Techniques
arXiv:2608.20776v1 [cs.SE] 21 Aug 2026
Ruihang Fan, Jiajun Jiang, Xinpeng Wang, Jiateng Fu, Fengjie Li and Jiasi Shen
Abstract—Automated code translation is increasingly important for software evolution, yet the relative strengths and limitations of learning-based and large language model (LLM)based techniques remain insufficiently understood. To address this gap, we conduct a large-scale empirical study comparing representative code translation techniques across methodological paradigms and translation granularities. We evaluate learningbased methods, LLM-based methods, and general-purpose LLMs on multilingual method-level and class-level benchmarks involving multiple programming languages. Our analysis considers executable correctness, code similarity, translation direction, translation granularity, and failure patterns. The results show that LLMs and LLM-based methods generally outperform learningbased methods in method-level correctness, although similarity metrics alone do not reliably reflect functional correctness. Translation direction substantially affects performance, particularly when translating between languages with different type-system characteristics. Class-level translation remains considerably more difficult than method-level translation because it requires preserving global semantics, interfaces, member relationships, and cross-method dependencies. Our error analysis further shows that static semantic errors and logical errors are the primary challenges in existing code translation systems. These findings provide empirical evidence and practical guidance for developing more robust, type-aware, structure-aware, and context-aware code translation techniques. Index Terms—Code translation, Program migration, Empirical study
I. I NTRODUCTION ODE translation, the process of automatically converting source code into functionally equivalent versions in other programming languages, has become a cornerstone of modern software evolution. It underpins critical tasks such as cross-platform program migration [1]–[3], legacy system modernization [4], [5], and library upgrades [6], [7]. As software systems evolve rapidly, the demand for such automated translation has grown substantially, since manual translation remains resource-intensive and time-consuming, while automation techniques can significantly reduce developer effort and maintenance costs [8], [9]. Consequently, automated techniques have emerged to address this need. Over the past few decades, a plethora of approaches have been proposed, ranging from early rigid, rule-based methods
C
Jiajun Jiang is the corresponding author. Ruihang Fan, Jiajun Jiang, Xinpeng Wang, Jiateng Fu and Fengjie Li are with School of Computer Software, College of Intelligence and Computing, Tianjin University, Tianjin 300350, China. Jiasi Shen is with the Department of Computer Science and Engineering, The Hong Kong University of Science and Technology, Hong Kong 999077, China. (E-mail: {frexvite, jiangjiajun, wxp3023244137, world 2004, fengjie}@tju.edu.cn; sjs@cse.ust.hk).
grounded in abstract syntax trees and pattern matching [10]– [15], to sophisticated deep learning models [16]–[24], and, most recently, techniques based on large language models (LLMs) [25]–[28]. In recent years, methods from different paradigms have achieved impressive results according to their respective metrics, yet the rapid pace of development has outpaced our understanding of their relative strengths and weaknesses. Although several empirical studies on code translation techniques have been conducted [29]–[34], they have typically adopted tools from only a single paradigm, i.e., either exclusively LLM-based methods or purely neural translation approaches. Consequently, there remains a lack of systematic, large-scale empirical research that performs genuine crossparadigm, cross-task level, and cross-dataset comparisons of existing code translation techniques under unified settings, in order to assess the current state of the art. To fill this gap, we conduct an extensive empirical study to systematically evaluate representative advanced techniques. Specifically, we first survey existing automated code translation approaches, primarily published between 2020 and 2025, and apply rigorous selection criteria, ultimately identifying 11 state-of-the-art representative techniques. These include four deep learning based methods (VIM-PT, StructCoder, TransCoder-ST, and a general-purpose code model, CodeT5+), four LLM-based methods (two variants of InterTrans, UniTrans, and ExeCoder), along with three recent general-purpose LLMs (GPT-3.5, GPT-4o-mini, and DeepSeek-V4-Flash). Finally, we conduct experiments on two method-level multilingual benchmarks and one class-level translation benchmark (G-TransEval, TransCoder-Uni, and ClassEval-T) to enable comprehensive and fair comparisons across code translation tasks involving five programming languages (C++, C#, Java, JavaScript, and Python). Through in-depth analysis of the experimental results, we derive a set of findings, among which we highlight the following findings: LLM-based methods generally achieve better correctness on method-level translation. LLMs and LLM-based methods generally outperform learning-based methods in CA and CSR. However, improvements over the corresponding base LLM are not uniform and depend on the method design, the capability of the base model, and the target task. The advantage of LLM-based methods is also less pronounced when measured by CodeBLEU. • Translation direction affects correctness. The direction of code translation has a clear impact on translation performance. Translating from statically typed languages to dynamically typed languages generally achieves better re•
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
sults than translating in the opposite direction, whereas the reverse direction tends to perform worse. This effect is also influenced to some extent by the inherent characteristics of the benchmark dataset. • Class-level translation remains substantially more difficult than isolated method-level translation. On ClassEvalT, methods obtain relatively high CSR but much lower CA, indicating that producing compilable class-level code is considerably easier than preserving class semantics, member relationships, and behavioral equivalence. • Language effects are pronounced in class-level translation. Within the class-level setting, translations targeting Python generally achieve higher CA than translations targeting Java or C++, while translation into C++ is particularly difficult in several directions. Larger contexts and crossmember dependencies amplify the challenges introduced by language-specific type and structural constraints. • Static semantic and logical errors are the dominant failure categories. Among the sampled method-level failed cases, static semantic errors account for 49.37% and logical errors account for 27.46%, together comprising 76.83% of all failures. At the class level, static semantic errors account for 70.67% of the sampled failures. Function signature violations are the most common static semantic error, highlighting the difficulty of type mapping, interface preservation, symbol binding, and logical equivalence. These findings lead to several implications for future research. In particular, code translation systems should move beyond isolated method-level translation, combine correctnessoriented and similarity-oriented evaluation, explicitly address direction-specific type inference and type mapping, and strengthen semantic verification for larger translation units. In summary, this paper makes the following contributions: To the best of our knowledge, we conduct the first largescale empirical study that evaluates code translation techniques across multiple methodological paradigms and translation granularities, including 11 representative techniques spanning learning-based methods, LLM-based methods, and general-purpose LLMs under unified experimental settings. • We perform a cross-paradigm, cross-dataset, and crossgranularity evaluation using two method-level multilingual benchmarks and one class-level translation benchmark. This enables controlled comparisons across translation methods, programming languages, translation directions, and translation units. • We provide a multi-dimensional analysis of code translation performance based on correctness and similarity metrics, including an investigation of language-direction effects, benchmark characteristics, and the differences between method-level and class-level translation. • We conduct a systematic manual analysis of translation failures. We annotate 570 method-level failed outputs and 150 class-level failed outputs using a structured error taxonomy, with high inter-rater agreement measured by Fleiss’ kappa. The analysis identifies static semantic errors, logical errors as major challenges. • We summarize a set of findings and implications for •
2
developing more robust, type-aware, and context-aware code translation techniques, and open-source the experimental results and associated implementations to facilitate replication and future comparison. II. R ELATED W ORK A. Code Translation Methods Numerous code translation methods have been proposed to automatically convert source code written in one programming language into another functionally equivalent code in another language. Existing approaches can be broadly categorized into rule-based, learning-based, and LLM-based methods. We also provide a brief summary of the recent representative methods in Table I, showing the publishing year, supported languages, the benchmarks used for evaluation, and whether the source code is open-source. Rule-based methods perform translation through handcrafted rules that explicitly map source-language constructs to their counterparts in the target-language. Represent works include MetaLift [35], DuoGlot [12], CxGo [15], Sharpen [10] and C2Rust [11]. These methods typically operate by parsing source code into structured intermediate forms and then applying predefined transformation rules to produce targetlanguage code. However, most of them are language-specific and require substantial manual effort to construct and maintain the translation rules. As a result, they are difficult to adapt to newly introduced features, evolving language standards, and the translated code may still require manual refinement [36]. Learning-based methods learn translation patterns from data instead of relying on hand-crafted rules. Early machine learning–based approaches to code translation were largely inspired by statistical machine translation (SMT). Nguyen et al. [8] investigated whether SMT techniques developed for natural languages could be adapted to programming languages. Karaivanov et al. [37] explored phrase-based methods and demonstrated the feasibility of SMT-based code translation. Nguyen et al. [2] further proposed mppSMT, a divide-andconquer method that achieved strong performance at that time. Later, deep neural networks were introduced for code translation. Chen et al. [38] proposed a tree-based neural model for translating between JavaScript and CoffeeScript. However, such supervised approaches are often constrained by the availability and quality of parallel corpora. To address this limitation, Roziere et al. [9] introduced TransCoder, a fully unsupervised neural transcompiler. And follow-up works further improved it with unit test filtering and intermediate representations [23], [39]. LLM-based methods have recently emerged as a promising direction for code translation. Unlike earlier learningbased approaches that mainly depend on task-specific training, these methods typically leverage the reasoning and iterative refinement abilities of LLMs to improve translation quality. For example, Jana et al. [26] presented CoTran, which finetunes an LLM with reinforcement learning guided by compiler and symbolic execution feedback, directly optimizing for compilation correctness and functional equivalence. Zheng et al. [42] introduced CodeGeeX, a large multilingual pretrained model capable of both code generation and translation
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
3
TABLE I: A brief summary of code translation techniques. Name TransCoder [9]
Rule-based
LLM-based
Learning-based
PLBART [40] TransCoderST [23]⋆
Year↑ 2020 2021 2021
Supported Languages C++, Java, Python C#, Java C++, Java, Python C++, Go, Java, Rust C#, Java C#, Java C++, Java, Python Java, Python C#, Java C/C++, C#, Java, JavaScript, Python, PHP
TransCoder-IR [39]
2022
NatGen [22] Contrabert [24]
2022 2023
SDA-Trans [1]
2023
SumGenToBT [41] StructCoder [19]⋆
2023 2024
VIM-PT [20]⋆
2024
CodeT5 [17] CodeT5+ [18]⋆ CodeGeeX [42]
2021 2023 2023
FSCTrans [43]
2024
Mftcoder [44] CodeFuse-13B [45]
2024 2024
multiple Multiple Multiple C#, Java, Python Multiple Multiple
TransAGENT [28]
2024
Multiple
CoTran [26] UniTrans [27]⋆ InterTrans [25]⋆
2024 2024 2025
ExeCoder [46]⋆
2025
Multiple Multiple Multiple C++, Java, Python
Sharpen [10] C2Rust [11] CxGo [15]
2008 2018 2021
DuoGlot [12]
2023
MetaLift [35]
2023
C#, Java C++, Rust C++, Go Python, JavaScript C++, Java
Benchmark D1 D4 D1
OSS ✓ ✓ ✓
TABLE II: Benchmarks for code translation evaluation. Name
Year↑
Languages
Probs.
Tests
D1. TransCoder-test [9]
2020
C++, Java, Python
948
✓
D2. CodeNet [47]
2021
C/C++, Go, Java, Python
200
✗
D3. AVATAR [48]
2021
Java, Python
250
✗
D4. CodeXGLUE [49]
2021
C#, Java
1000
✗
D5. CoST [50]
2022
C/C++, C#, Java, JavaScript, Python, PHP
1625
✗
D1
✓
D4 D4
✓ ✓
D6. XLCoST [51]
2022
C/C++, C#, Java, JavaScript, Python, PHP
11265
✓
D1
✗
D7. G-TransEval [31]
2023
C++, C#, Java, JavaScript, Python
400
✓
D1 D4
✓ ✓
2023
C++, Go, Java, JavaScript, Python
164
✓
D5
✓
D9. TransCoder-Uni [27]
2024
C++, Java, Python
568
✓
D10. AVATAR-TC [52]
2024
Java, Python
1746
✓
D4 D4 D8, D6
✓ ✓ ✓
D11. ClassEval-T [30]
2025
C++, Java, Python
94
✓
D1, D4
✓
CodeFuseEval CodeFuseEval TransAGENTtest D10 D9 D8, D1, D2 TransCodertest-X
✓ ✓
-
✓ ✓ ✓
D1
✓
Spark, Domino
✓
✗ ✓ ✓ ✓ ✓
“⋆”: studied methods in this paper. “-”: the tool did not explicitly evaluate on any benchmarks, and “Dk” denotes dataset shown in Table II.
across 23 programming languages, with its evaluation benchmark HumanEval-X extending beyond Python to multiple languages. Yang et al. [27] proposed UniTrans, which enhances translation through automated test-driven feedback. Yuan et al. [28] introduced TranAgent, a multi-agent framework that uses multiple LLMs to correct syntactic and semantic errors during translation. Macedo et al. [25] developed InterTrans, which leverages intermediate languages to bridge syntactic gaps between source and target languages. Additionally, a wide range of LLMs for code generation can also be applied to code translation tasks, such as CodeBERT [16], CodeT5 [17], CodeT5+ [18], and MftCoder [44]. Several of these models have achieved strong performance on code translation benchmarks and are even regarded as competitive baselines—CodeT5+ being a notable example. B. Code Translation Benchmarks Over the past few years, several benchmarks have been proposed for evaluating code translation methods. CodeNet [47] provides large-scale parallel programs collected from online coding platforms, covering 55 different programming languages. Ahmad et al. introduce Avatar [48], which focuses on more challenging Python–Java translation tasks. CodeXGLUE [49] provides a code-to-code translation benchmark based on parallel Java–C# programs. Although they
D8. HumanEval-X [42]
*“Probs” denotes the number of programming problems covered in the dataset.
cover a wide range of programming languages, many of them lack executable test cases, which limits the reliable evaluation of the functional correctness of translated code. More recent benchmarks address this issue by providing executable test suites. Roziere et al. [23] proposed a benchmark (referred to as TransCoder-Uni) from GeeksforGeeks programs in Python, C++, and Java, and 568 out of 948 cases include test suites. Jiao et al. [31] introduced G-TransEval, which contains 400 parallel translation instances across five languages, along with difficulty labels and complete test suites for every language pair. Xue et al. [30] proposed ClassEvalT, a class-level code translation benchmark covering Python, C++, and Java, featuring longer code snippets, complex dependencies, and comprehensive test suites. We list several recognized benchmarks in the field of code translation in Table II. After our verification, all benchmarks in the table have been used by at least two works in the code translation domain.
C. Empirical Studies on Code Translation To investigate the effectiveness of existing code translation techniques, several studies have been conducted. Jiao et al. [31] proposed a four-type taxonomy for code translation and systematically evaluated state-of-the-art neural translation models across these translation types. Gong et al. [53] studied the execution efficiency of LLM-based code translation, and Pan et al. [32] studied the effectiveness of LLMs for automated code translation and analyzed LLM-introduced translation bugs. UniTrans [27] further enhanced code translations through test generation, execution-based checking, and iterative repair. Tao et al. [34] further introduced PolyHumanEval and used it to conduct a large-scale empirical study of LLMbased code translation. However, these studies either focus on neural or LLM-based (especially focus on end-to-end LLM methods) methods or are limited to a small set of programming languages and evaluation perspectives. In contrast, our work aims to compare both recent learning-based and LLM-based methods under a unified setting and provides a more comprehensive evaluation from multiple perspectives, including quantitative metrics and error type analysis.
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
III. M ETHODOLOGY A. Code Translation Method Selection As mentioned in the introduction, existing studies predominantly focus on individual paradigms (e.g., LLM-based methods, especially focus on end-to-end LLMs), while a systematic comparison of different approaches under a unified setting remains underexplored. As discussed in Section II-A, numerous code translation methods have been proposed in the past decade. This study aims to comprehensively compare the performance of the latest state-of-the-art techniques. Accordingly, we focus on methods published between 2020 and 2025. We further limit our scope to open-source approaches, primarily for two reasons: (1) reproducing a large number of methods would require significant time and effort, and (2) reimplementations often fail to achieve the performance reported in the original papers, potentially confounding the evaluation of each method’s intrinsic capabilities. Finally, we selected the representative methods from two categories, i.e., learning-based and LLM-based approaches (listed in Table I), to ensure the feasibility of our study and the reliability of our experimental results. To identify the most representative approaches within these categories, we applied the following three selection criteria. 1) Performance (outstanding performance): Among methods developed under comparable timelines, we prioritize those achieving best performance on at least one benchmark, ensuring that selected systems genuinely represent the current best performance within their respective technical paradigms. 2) Recency (latest techniques): Higher preference is given to models and methods released or updated after 2024, so that our experiments can reflect the latest advancements in the field of code translation. 3) Language diversity (applicable to diverse languages): We favor methods supporting the largest number of programming languages, aiming to obtain more comprehensive and generalizable experimental results. Based on the above criteria, we ultimately selected eight state-of-the-art code translation methods from existing studies. These methods include four learning-based approaches (three translation-specific methods: VIM-PT, StructCoder, TransCoder-ST, and one general-purpose code model: CodeT5+), as well as four LLM-based methods (two variants of InterTrans, UniTrans, ExeCoder). The rationale is as follows: VIM-PT, StructCoder, UniTrans, ExeCoder and InterTrans are the best-performing open-source methods in recent years in the fields of learning-based code translation and LLM-based code translation, respectively (TransAGENT surpasses UniTrans but is not open-source). TransCoder-ST and CodeT5+ have been employed as classic competitive baselines in prior code translation studies, and we include them in our experiments to obtain more representative results [19], [26], [27], [43]. In addition, to conduct a comprehensive evaluation, we also incorporate three recent general-purpose LLMs into our study, which have demonstrated outstanding performance across various software engineering tasks [54]–[56], including two commercial LLMs (GPT-3.5-turbo and GPT-4o-mini) and
4
one open-source LLM (DeepSeek-V4-Flash). Consequently, we investigate 11 representative approaches in our evaluation, which (except for LLMs) are marked with ⋆ in Table I and described in detail below. VIM-PT [20]: A unified multilingual program translation model based on variational inference and information disentanglement. It jointly learns language-shared semantics and language-specific features, effectively leveraging nonparallel and partially missing data to significantly improve accuracy and generalization in cross-language code translation. StructCoder [19]: A structure-aware Transformer model that explicitly incorporates abstract syntax trees (ASTs) and data flow graphs (DFGs) into both encoder and decoder. It further enhances performance on code translation and textto-code generation by introducing two auxiliary tasks in the decoder: AST path prediction and data flow prediction. TransCoder-ST [23]: An unsupervised code translation approach based on self-training. It automatically generates high-coverage unit tests for source code and uses these tests to filter semantically equivalent translations, thereby constructing high-quality pseudo-parallel corpora for iterative model refinement. CodeT5+ [18]: A model featuring that supports encoderonly, decoder-only, and encoder-decoder modes within a unified architecture. It is trained with multi-stage objectives, including span denoising, causal language modeling, contrastive learning, and text-code matching, and achieves strong performance across code understanding and generation tasks. InterTrans [25]: An LLM-based code translation method that constructs an “intermediate-language translation path” and employs tree search combined with test verification to substantially improve functional correctness in crosslanguage translation. In our experiments, we use InterTrans implementations based on Magicoder-SDS-7B [57] and StarCoder2-15B [58], referred to hereafter as IT(Magi) and IT(Star), respectively. UniTrans [27]: A general-purpose LLM-based code translation framework that validates and repairs translation outputs by generating and executing test cases. It further iteratively refines prompts using error feedback to enhance both functional correctness and robustness in cross-language code translation. ExeCoder [46]: An LLM specifically designed for code translation, aimed at utilizing executability representations such as functional semantics, syntax structures, and variable dependencies to enhance the capabilities of LLMs in code translation. GPT-3.5-turbo [59]: An efficient and cost-balanced LLM from OpenAI. It was widely used as a baseline for code understanding and generation tasks in previous studies [27]. Specifically, we adopted the version of GPT-3.5-turbo-1106 in our experiment. GPT-4o-mini [60]: A lightweight OpenAI model offering low latency and strong reasoning capabilities, ideal for real-time applications and code generation. Specifically, we
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
employed the version of GPT-4o-mini-2024-07-18 in our experiment. DeepSeek-V4-Flash [61]: A high-performance model from DeepSeek featuring a Mixture-of-Experts architecture, delivering strong results in code and reasoning tasks with high cost-effectiveness. B. Benchmark Selection As introduced in Section II-B, a number of benchmarks for code translation have been proposed, as shown in Table II. Similarly, we also applied several selection criteria analogous to those used for the studied method selection: 1) Multilingual (covering diverse languages): To enable a comprehensive comparison among diverse methods and investigate their translation performance when applied to different programming languages of the same task (A task denotes a distinct function regardless of implementation languages), we prefer the benchmarks that have more tasks and involve more parallel implementations of different languages. 2) Verifiability (including test suite): Since the same functionality can be implemented in different ways, directly comparing the equivalence of the translated code to the ground-truth implementation is insufficient. To enable a more in-depth analysis and make the evaluation results verifiable in an automatic manner, we require the benchmark including associated test suites, which play as the (incomplete) semantic specification of the target code, and thus can automatically and reliably examine the functional correctness of the translated code. 3) Compatibility (applicable to studied methods): We require that the benchmarks should accommodate as many of the selected methods introduced in Section III-A, facilitating more generalizable conclusions rather than findings limited to a single dataset. According to these selection criteria, we ultimately selected two representative method-level code translation benchmarks in this study, G-TransEval and TransCoder-Uni (the cleaned version of the TransCoder-ST dataset prepared by Yang et al. [27]), as well as one class-level code translation benchmark, ClassEval-T [30], involving 1,062 distinct translation tasks in total. All three benchmarks feature comprehensive test suites and multilingual parallel implementations. For the methodlevel benchmarks, they are applicable to nearly all of our studied methods, while the class-level benchmark is also compatible with most large language models and LLM-based approaches (learning-based methods are difficult to adapt due to context length limits). We also emphasized these three datasets in bold in Table II. We exclude XLCoST from testtime evaluation because it is used for fine-tuning the learningbased methods in our study (Section IV-C). IV. E XPERIMENTAL S ETUP A. Research Questions In this study, we aim to answer the following research questions:
5
RQ1: How do existing methods perform overall on method-level code translation tasks? To answer this question, we conduct extensive experiments on two largescale benchmarks and compare the overall correctness of all selected methods. Specifically, we evaluate the translated code using compilation and functional correctness metrics, and further analyze the results with CodeBLEU for a multidimensional view of translation quality. RQ2: How do existing methods perform on different translation tasks and language directions? Since the same method may behave differently when translating between different language pairs or in opposite directions, we further investigate task-level performance variations across sourcetarget language combinations. This RQ aims to identify language-direction effects and examine how programming language characteristics influence translation performance. RQ3: How does code translation perform at the class level? Compared with method-level translation, class-level translation involves longer contexts, richer inter-method dependencies, and more complex type structures. In this RQ, we extend the evaluation to class-level code translation and study whether existing methods can still preserve correctness under more complex code contexts. RQ4: What kinds of translation errors do current methods commonly make? Although existing methods achieve strong performance overall, they still produce incorrect outputs. To better understand these failures, we manually analyze translation errors produced by the selected methods, categorize them into major error types, and examine their distributions across datasets and methods. B. Evaluation Metrics We use three evaluation metrics: Computational Accuracy (CA), Compilation Success Rate (CSR), and CodeBLEU (CB) [62]. Following prior work [9], [23], [27], CA measures the proportion of generated programs that pass all official test cases, while CSR measures the proportion that compile successfully. CodeBLEU measures the similarity between generated code and reference code by combining n-gram matching, keyword matching, abstract syntax tree matching, and data flow matching. We use the standard setting in which all four components are equally weighted. We collectively refer to CA and CSR as correctness metrics, since they measure the functional and syntactic correctness of generated code. We refer to CodeBLEU as a similarity metric, since it evaluates how closely the generated code matches the reference implementation in textual and structural terms. C. Implementation and Configuration Learning-based Methods. For TransCoder-ST [23], we used the best checkpoint provided by the original authors. For VIM-PT [20], StructCoder [19], and CodeT5+ [18], we followed prior work and trained/fine-tuned the models on the XLCoST [51] dataset. In addition, because TransCoderUni and XLCoST are derived from the same data source, we removed from the training set any examples that overlap
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
6
TABLE III: Configurations of hyperparameters for model training. Hyperparameter Parameter size Learning rate Batch size Gradient accumulation steps Epoch *
StructCoder
VIM-PT
CodeT5+
∼ 224M 1e-5 25 / 25
∼ 222M 1e-4 8 2 25*
∼ 220M 5e-5 8 4 10
VIM-PT includes 10 auto-encoding epochs and 15 formal epochs.
with our evaluation benchmarks. The training hyperparameters are listed in Table III, and all settings follow the default configurations of the corresponding open-source repositories. For each method, we evaluated using the checkpoint that achieved the best performance on the validation set. This choice was motivated by two factors: 1) learning-based methods exhibit less randomness compared to LLMs; 2) repeated training would incur substantial computational costs (e.g., VIM-PT training took approximately 1,266 GPU hours). LLM-based Methods. The officially released UniTrans [27] cannot be directly executed on G-TransEval [31] due to the tight coupling of part of its code with the source dataset. We therefore adapted the modules for general translation enhancement and translation repair to evaluate and rectify translation outputs generated by LLMs. For each method, we follow prior works [27], [30] and set the hyperparameters to temperature = 0.8, top p = 0.9, and n = 1, i.e., only the first generated output was used. We then conducted three independent runs and reported the average results. Experimental environment Our experiments were conducted on a local machine equipped with dual Intel Xeon 6388 CPUs, 512GB RAM, and two NVIDIA A800-SXM4-80GB GPUs, running Ubuntu 20.04.6LTS. V. R ESULTS A NALYSIS A. RQ1: Method-Level Code Translation Performance In this research question, we evaluate the overall performance of different approaches on two large-scale benchmarks. Specifically, we consider the first output of each method by default, namely CA@1 and CSR@1, and further use CodeBLEU as a similarity metric for multi-dimensional evaluation. Table IV and Table V report the correctness results of different tools across all language pairs on G-TransEval [31] and TransCoder-Uni [27], respectively. Figure 1 and Figure 2 show the distributions of different metrics for all methods. Detailed CodeBLEU results are available on the project website. In terms of correctness metrics, LLM-based methods, including general-purpose LLMs and methods enhanced for code translation, generally outperform state-of-the-art learning-based methods across metrics and datasets. Specifically, except for IT(Star), most LLM-based methods maintain high average CA and CSR scores on both datasets, clearly outperforming traditional learning-based methods. In contrast, the best-performing learning-based method, TransCoder-ST, achieves CA and CSR scores of only 56.96% and 70.50%,
respectively, which are much lower than those of most LLMbased methods. Overall, among all translation tasks, UniTrans achieves the best performance, with average CSR (CA) scores of 96.01% (94.36%) on G-TransEval and 96.59% (91.66%) on TransCoder-Uni, significantly outperforming not only learning-based methods but also other LLM-based approaches. Among all methods that enhance performance using large language models, UniTrans improves the CSR (CA) over its base model (GPT-3.5-turbo) by 1.18 percentage points (1.13 percentage points) and 1.44 percentage points (1.57 percentage points) on the two datasets, respectively, while ExeCoder and IT (Magi) achieve performance close to that of GPT-4o-mini. This suggests, to some extent, that current LLM methods designed for enhancing code translation tasks generally achieve stable and relatively high correctness, but the extent of improvement over the base LLM still depends on the specific method design, the capability of the base model, and the particular task at hand. Finding 1: In method-level code translation tasks, LLMs and LLM-based methods significantly outperform learning-based methods in correctness metrics. Methods enhanced for code translation usually achieve strong performance, but their improvements over base LLMs depend on the specific method design, the capability of the base model, and the target tasks. In terms of similarity metrics, almost all methods achieve average CodeBLEU scores above 70.00% on both datasets. However, the advantage of LLM-based methods on this metric is less pronounced than on correctness metrics. Specifically, although learning-based methods usually obtain lower CA scores, their similarity scores are close to those of LLM-based methods. For example, StructCoder and VIM-PT perform poorly in correctness metrics, but their similarity scores are close to those of UniTrans. This indicates that learning-based methods often generate outputs that are superficially similar to the reference translations but fail to compile or pass tests. To further investigate this phenomenon, we group all passed and failed outputs generated by different methods and compute their CodeBLEU scores. We exclude InterTrans to avoid the impact of empty parser outputs on the calculation. As shown in Figure 3, the average CodeBLEU gap between passed and failed samples is 15.96% to 28.32% for learning-based methods, while it is only 9.51% to 13.25% for LLM-based methods, which is substantially smaller. This suggests that LLM-based methods tend to generate functionally correct outputs even when their surface similarity to the reference is relatively low, indicating that they focus more on understanding the semantic functionality of source programs rather than performing line-by-line translation. Combining correctness and similarity analyses, we conclude that recent advances in LLMs have dominant effectiveness in code translation: they consistently outperform learning-based methods, provide more robust translation results, and emphasize functional equivalence rather than surface similarity.
JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2021
7
TABLE IV: Translation performance on G-TransEval across methods. The table shows results for both translation directions (e.g., Java to C# and C# to Java) between each pair of languages (e.g., Java⇌C#). Empty cells indicate that the corresponding method is not applicable. A color gradient is used, darker shades highlight larger values and thus better performance (%). Name
DS-V4-Flash GPT-3.5-turbo GPT-4o-mini UniTrans
Java⇌C#
Java⇌C++
Java⇌Py.
Java⇌JS
C++⇌Py.
C++⇌JS
C++⇌C#
Py.⇌C#
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
CSR
CA
99.17 99.92 98.92 99.92 96.75 99.00 99.25 100.00
98.92 99.92 98.58 99.67 96.33 98.33 96.08 99.83
92.67 99.75 94.42 99.17 90.00 97.50 99.42 100.00 81.50 92.92 94.33 93.00 70.08 81.17
92.67 99.75 94.25 99.17 88.58 96.67 99.25 99.67 77.58 90.83 91.17 90.83 66.67 78.83
99.75 93.25 99.42 92.83 99.08 85.67 99.50 95.50 98.83 82.92 92.75 92.75 75.67 78.67
99.58 91.75 98.92 90.33 96.17 81.58 99.17 93.17 94.08 74.92 87.25 85.58 66.83 70.92
99.00 92.17 99.50 91.92 98.58 88.00 99.75 93.83
97.42 88.92 97.50 89.58 93.17 84.17 93.17 91.17
96.92 74.17 96.67 77.42 92.25 71.67 92.92 90.42
98.33 93.17 98.83 96.08 91.75 95.08 99.33 99.33
98.08 92.83 98.17 95.67 91.00 92.67 96.67 99.00
88.17 99.25 89.42 99.33 68.17 98.67 88.08 99.42
86.92 99.08 86.42 98.75 64.42 95.75 83.58 98.83
96.08 99.50 96.08 99.58 95.50 97.92 97.58 99.75
93.33 99.50 91.17 99.25 86.67 96.08 93.92 99.33
97.67 80.00 98.83 87.58 98.33 69.00 98.83 86.75
96.50 75.42 96.42 84.50 92.33 65.92 97.00 82.42
90.50 89.17 58.17 77.08
99.25 76.33 96.17 76.08 94.75 62.25 95.75 89.67 92.25 59.83 92.25 68.67 54.92 45.17
98.67 77.58 99.25 79.92 98.58 74.17 99.33 87.58
97.50 93.75 69.50 81.17
99.42 77.67 96.75 78.92 97.33 67.00 97.58 92.25 96.33 67.75 97.67 77.00 61.50 51.67
97.25 75.75 59.58 51.75
90.42 68.67 48.08 47.00
94.00 84.75 59.75 48.33
91.58 81.50 58.08 46.00
83.08 98.50 55.08 68.58
74.83 93.75 51.08 60.67
94.25 93.33 66.83 70.83
80.75 89.00 53.42 67.42
97.33 81.00 61.58 52.42
90.58 91.48 85.90 73.92 48.83 65.17 59.30 50.00
51.25 31.00 84.00 70.00 84.25 55.00
21.75 24.75 70.25 52.50 63.75 45.50
66.50 43.75 47.25 40.00 35.50 29.25 71.00 53.25 81.75 63.00 83.25 55.50 48.50 50.75
17.75 19.25 60.50 35.75 66.50 39.50
61.75 42.25 49.00 44.25 33.50 24.00 50.50 26.75 63.50 43.25 48.10 34.30 46.00 40.75 53.25 48.00 50.75 20.00 50.00 13.50 43.00 40.00
ExeCoder
95.42 IT(Magi) 92.17 65.17 IT(Star) 71.67 20.50 StructCoder 18.00 52.00 52.25 48.00 VIM-PT 40.75 44.75 39.75 76.00 64.75 TransCoder-ST 68.75 58.00 75.00 67.25 62.75 54.00 CodeT5+ 57.75 53.25 60.50 55.25
C#⇌JS
Average CSR
CA
94.06 92.86 94.83 93.23 90.30 87.04 96.01 94.36 86.71 81.58
22.88 19.25
70.50 56.96 79.50 59.75 71.50 64.25 60.25 51.25 80.25 56.50 79.00 59.25 68.80 56.06 52.25 44.00 58.00 49.00 86.25 65.00 81.00 63.00 61.50 52.75