Skip to main content
QUICK REVIEW

[Paper Review] Revisiting the Role of Natural Language Code Comments in Code Translation

Monika Gupta, Ajay Kumar Meena|arXiv (Cornell University)|Jan 23, 2026
Natural Language Processing TechniquesComputer Science0 citations
TL;DR

The paper empirically studies how natural language code comments influence LLM-based code translation across five languages and proposes COMMENTRA to selectively add comments for improved translation.

ABSTRACT

The advent of large language models (LLMs) has ushered in a new era in automated code translation across programming languages. Since most code-specific LLMs are pretrained on well-commented code from large repositories like GitHub, it is reasonable to hypothesize that natural language code comments could aid in improving translation quality. Despite their potential relevance, comments are largely absent from existing code translation benchmarks, rendering their impact on translation quality inadequately characterised. In this paper, we present a large-scale empirical study evaluating the impact of comments on translation performance. Our analysis involves more than $80,000$ translations, with and without comments, of $1100+$ code samples from two distinct benchmarks covering pairwise translations between five different programming languages: C, C++, Go, Java, and Python. Our results provide strong evidence that code comments, particularly those that describe the overall purpose of the code rather than line-by-line functionality, significantly enhance translation accuracy. Based on these findings, we propose COMMENTRA, a code translation approach, and demonstrate that it can potentially double the performance of LLM-based code translation. To the best of our knowledge, our study is the first in terms of its comprehensiveness, scale, and language coverage on how to improve code translation accuracy using code comments.

Motivation & Objective

  • Assess how natural language code comments affect LLM-based code translation quality.
  • Analyze comment characteristics (intent, density, language, location) and their impact on translation performance.
  • Develop and evaluate a comment-based translation framework (COMMENTRA) that selectively inserts comments to improve results.
  • Provide cross-language benchmarks and insights to guide comment usage in translation pipelines.

Proposed method

  • Assemble 1100+ unique code samples from AVATAR and CodeNet across C, C++, Go, Java, and Python.
  • Generate comments with multiple commenting LLMs and translate commented and uncommented code using several translating LLMs.
  • Systematically vary comment factors (intent, density, language, placement) and measure translation success via compilation and test outcomes.
  • Introduce COMMENTRA, an iterative translation approach that adds comments only when initial translations fail, to improve efficiency and accuracy.
Figure 1 : Experimental Setup; The exact prompts used are also shown here.
Figure 1 : Experimental Setup; The exact prompts used are also shown here.

Experimental results

Research questions

  • RQ1RQ1 - Usefulness of Code Comments: Do natural language code comments help LLMs improve translation performance?
  • RQ2RQ2 - Intent of Code Comments: Can we classify comment intent and understand utility across intents?
  • RQ3RQ3 - Density, Language of Code Comments: How do comment density and language affect translation accuracy?
  • RQ4RQ4 - Location of Comments: How does placement of comments influence translation outcomes?

Key findings

  • Code comments can both help and hurt translation performance, with gains and losses depending on models and language pairs.
  • Commenting models like GPT and DeepSeek often yield better improvements than some alternatives, but effects vary by context.
  • English comments generally provide the strongest gains for Java-to-Python and Python-to-Java translations, with some exceptions.
  • Arbitrary limits on comment density do not consistently improve performance; effective guidance for selective commenting remains open.
  • In-code comments outperform pseudocode or standalone method specifications for improving translation quality.
  • The proposed COMMENTRA framework delivers substantial improvements by iteratively inserting comments only when initial translations fail.
Figure 2 : Venn diagrams depicting increase and decrease in LLMs performance in the commented code samples. Left and center diagrams show the overlap between uncommented successful and successfully translated model-commented samples; the right diagrams show the overlap between the various successful
Figure 2 : Venn diagrams depicting increase and decrease in LLMs performance in the commented code samples. Left and center diagrams show the overlap between uncommented successful and successfully translated model-commented samples; the right diagrams show the overlap between the various successful

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.