Can Emulating Semantic Translation Help LLMs with Code Translation? A Study Based on Pseudocode

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Chen, Songqiang, Xu, Congying, Chen, Jingyi, Cao, Jialun, Wu, Jiarong, Cheung, Shing-Chi
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866914340734500864
author Chen, Songqiang
Xu, Congying
Chen, Jingyi
Cao, Jialun
Wu, Jiarong
Cheung, Shing-Chi
author_facet Chen, Songqiang
Xu, Congying
Chen, Jingyi
Cao, Jialun
Wu, Jiarong
Cheung, Shing-Chi
contents Although large language models (LLMs) show promising potential in code translation, they still struggle to generate accurate translations using the commonly adopted direct code-to-code translation approach, which converts an original program into the target programming language (PL) in a single step. Inspired by the success of incorporating intermediate steps to guide LLMs in resolving challenging tasks, in this study, we explore pseudocode-based code translation. This approach emulates human semantic translation by first interpreting the original program's intent and logic into pseudocode and then implementing it in the target PL. To understand the effectiveness of this underexplored approach, we present a systematic empirical study on pseudocode-based code translation, aiming to investigate its helpfulness in enhancing the direct translation approach, illuminate its effective usage, and identify its limitations. By comparing direct and pseudocode-based translation on 9,690 translation tasks across six PLs with five popular LLMs, we found that pseudocode-based translation can effectively complement direct translation, particularly when translating from flexible to rigid PLs and handling a low-training-resource PL. Based on the findings, we suggest combining the translation results of both approaches for test-based selection to leverage their complementary strengths. We also reveal the advantages of pseudocode-based translation in decoupling the code understanding and generation burden on complicated programs and mitigating distractions from PL-specific implementations in original programs, as well as its limitations due to incorrect, incomplete, or ambiguous pseudocode. Our study sheds light on the effective use of pseudocode-based translation and provides evidence to help enhance LLMs in code translation.
format Preprint
id arxiv_https___arxiv_org_abs_2510_00920
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Can Emulating Semantic Translation Help LLMs with Code Translation? A Study Based on Pseudocode
Chen, Songqiang
Xu, Congying
Chen, Jingyi
Cao, Jialun
Wu, Jiarong
Cheung, Shing-Chi
Software Engineering
Although large language models (LLMs) show promising potential in code translation, they still struggle to generate accurate translations using the commonly adopted direct code-to-code translation approach, which converts an original program into the target programming language (PL) in a single step. Inspired by the success of incorporating intermediate steps to guide LLMs in resolving challenging tasks, in this study, we explore pseudocode-based code translation. This approach emulates human semantic translation by first interpreting the original program's intent and logic into pseudocode and then implementing it in the target PL. To understand the effectiveness of this underexplored approach, we present a systematic empirical study on pseudocode-based code translation, aiming to investigate its helpfulness in enhancing the direct translation approach, illuminate its effective usage, and identify its limitations. By comparing direct and pseudocode-based translation on 9,690 translation tasks across six PLs with five popular LLMs, we found that pseudocode-based translation can effectively complement direct translation, particularly when translating from flexible to rigid PLs and handling a low-training-resource PL. Based on the findings, we suggest combining the translation results of both approaches for test-based selection to leverage their complementary strengths. We also reveal the advantages of pseudocode-based translation in decoupling the code understanding and generation burden on complicated programs and mitigating distractions from PL-specific implementations in original programs, as well as its limitations due to incorrect, incomplete, or ambiguous pseudocode. Our study sheds light on the effective use of pseudocode-based translation and provides evidence to help enhance LLMs in code translation.
title Can Emulating Semantic Translation Help LLMs with Code Translation? A Study Based on Pseudocode
topic Software Engineering
url https://arxiv.org/abs/2510.00920