Editor’s introduction
The study examined how prompting large language models—GPT-4o mini, DeepSeek, and Claude—with translations in Chinese, Hindi, Spanish, and Italian affects code output. It assessed functional correctness, structural quality, static analysis warnings, and language use in identifiers and comments across 460 coding tasks in Python and Java. Results show that English prompts do not consistently yield the highest code quality, and performance varies by both programming language and model. The generated code often mixes the prompt language with English in comments and string literals. This research provides the first curated benchmark for evaluating language bias in code generation, highlighting that prompt language significantly shapes output characteristics.
Introduction
Large Language Models (LLMs) have transformed software engineering automation by raising the bar to unprecedented levels, enabling practitioners to automate various coding tasks such as code generation, summarization, program repair, and testing –among other. The widespread adoption of commercial solutions such as GitHub Copilot and ChatGPT, which act as AI companions for developers, demonstrates the transformative power of LLMs in software engineering. However, this success comes with underlying challenges rooted in how these models are trained. LLMs learn by processing vast quantities of unstructured data from the wild, including source code, comments, documentation, and natural language descriptions. While this broad training approach enables learning from diverse sources, it introduces significant downsides.
Let us consider the following scenario. A developer, working in a country where English is not the main language, receives a specification written in their language. To seek assistance, the developer interacts, using their mother tongue, with an LLM-based assistant. When the query is posed in a language other than English, however, the output of the LLM may differ. This variation can arise from distribution shifts in the training data, since non-English content may be less prevalent or unevenly represented in the model’s training corpus.
Existing research has examined the quality of source code generated by LLMs, primarily focusing on correctness—which measures the ability of the model to generate code that passes test cases—and overall code quality. A previous preliminary study showed correctness differences in a programming contest, while another study has considered, on automatically-translated tasks from the HumanEval benchmark, the extent to which generated code from multilingual prompts passes different proportions of tests.
Our work studies bias in code generation from multilingual prompts considering three key additional aspects not dealt by previous work: (i) manually curated prompt translation (necessary to make prompts looking natural), (ii) quality seen not only in terms of passed test, but also using quality metrics and static analysis warnings, and (iii) the use of more complex tasks, from the CoderEval benchmark.
For prompts, we consider four languages other than English: Chinese, Hindi, Spanish, and Italian. The selection of these languages is based on their global prominence and linguistic diversity, ensuring a broad representation of writing systems. Chinese, one of the most widely spoken languages worldwide, employs a logographic writing system, which contrasts with the alphabetic systems used by the other selected languages (i.e., Italian and Spanish). Hindi, a major language in South Asia, is written in the Devanagari script and features a distinct linguistic and syntactic structure. Finally, Spanish and Italian represent Latin languages, with Spanish being an official language in 22 countries, and Italian representing a more geographically concentrated speaking population.
To conduct the study, we took 460 code generation tasks from the CoderEval benchmark and considered two popular programming languages, i.e., Python and Java. We began by creating code generation prompts from the benchmark queries–originally written in English–into the other four languages. In contrast to recent studies, the translated prompts were manually validated by native-speaker authors to minimize the risk of (mis)-translation and ensure the original intent of the prompts was accurately preserved. Then, we generated code with three state-of-the-art LLMs, i.e., GPT-4o mini, DeepSeek, and Claude.
Multilingual Inconsistencies in LLMs
Understanding the adaptability of LLMs across linguistic contexts remains underexplored, from high-resource languages such as English to other forms of languages, including those with a different alphabet and/or writing systems (e.g.,, Chinese, Hindi). If left unexamined, this disparity could reflect the performance gaps observed across various tasks, such as logical reasoning, natural language understanding, and natural language generation. Shi et al. highlighted these discrepancies by demonstrating that models such as GPT-3 and PaLM exhibited significantly lower accuracy when answering mathematical questions in underrepresented languages than when responding to the same queries in English. This lower accuracy can be due to the linguistic imbalance in training and alignment data, mostly in English. As we show in our study, possible consequences may occur in software engineering applications as well. Koyanagi et al. performed a preliminary study considering (i) a Japanese programming context translated into Chinese and English, and (ii) GitHub Copilot to generate code elements. They evaluated the correctness of the produced code and found that Japanese was on par with English and even outperformed it, while Chinese did not perform well. Our work goes beyond such an analysis, as we consider multiple programming languages, four languages, and three LLMs. Also, we look at code quality from other perspectives—i.e., metrics, static analysis warnings, and lexicon—beyond its correctness.
Moreover, we have avoided using similar benchmarks to avoid possible biases/leakages (e.g., a Japanese programming contest may bias results towards Japanese). Instead, we leverage a benchmark based on real-world source code tasks, for which, especially for Python, Chinese turned out to perform well. Peng et al. automatically translated the HumanEval benchmark into twenty-three natural languages for prompts and twelve programming languages for code. They then evaluated performance using the pass@1 metric across large language models (LLMs) of varying sizes. Our work introduces several novel contributions in comparison. First, we adopt CoderEval, a recent and more challenging benchmark that is currently one of the primary references for code generation, whereas Peng et al. rely on HumanEval, a benchmark that has been largely outperformed by contemporary models. Second, our evaluation goes beyond functional correctness by incorporating additional dimensions of code quality, including metric-based analysis, static analysis warnings, and lexical diversity. Third, we consider state-of-the-art LLMs that largely outperform those used by Peng et al. (they used GPT 3.5-turbo, and other models of 13B parameters or less). Last, and more importantly, we manually validated each prompt translation generated by GPT-4, ensuring accuracy and preserving intent. In contrast, the translations in, both for prompts and code, were not manually verified, potentially introducing significant bias. A possible approach to deal with prompt language bias is fine-tuning. However, this has been applied only on a relatively small model (T5-base, having 220M parameters) and may not be feasible on state-of-the-art models. Also, such a fine-tuning may create overfitting issues.
Compared to previous literature, our paper aims to investigate this issue through a systematic analysis that identifies potential biases and examines the quality of LLM-generated code in multilingual contexts. This analysis will contribute to enhancing fairness and accessibility in AI-driven SE tools, ensuring that developers across different linguistic backgrounds can effectively utilize these technologies, regardless of their primary language.
Study Design
The goal of our study is to investigate the quality of LLM-generated source code when developers write queries using different languages. The perspective is of developers who want to leverage (natural language) specifications written in their own language to generate source code with LLMs. The context consists of (i) 460 (230 for Python and 230 for Java) development tasks from the CoderEval benchmark, translated into four languages: Chinese, Hindi, Spanish, and Italian; and (ii) three state-of-the-art LLMs, i.e., GPT-4o mini, DeepSeek, and Claude.
RQ1: How does a prompt written in a language other than English impact code generation in terms of correctness? We assess whether task specifications (and consequently prompts) written in different languages affect the functional correctness of the generated code, hence possibly requiring better testing and code review.
RQ2: How does a prompt written in a language other than English affect code quality metrics, design issues, and static code analysis tool violations? We (i) look at whether the code is structurally different and more or less commented by examining source code metrics, and (ii) check code quality aspects by relying on static analysis tools that developers typically use in their daily work.
RQ3: How does a prompt written in a language other than English impact the source code lexicon? We look at the language of identifiers, comments, and string literals, as this might impact developers’ further interventions to ensure proper documentation and nationalization of the resulting code.
Code Quality Analysis
Our study analyzes the impact of prompt language on code generation quality through two key perspectives: quantitative code metrics (cyclomatic complexity, lines of code, comment ratios) and qualitative defect detection (code smells, resource leaks). We employ standard static analysis tools to systematically compare how different languages influence the structural and functional characteristics of LLM-generated code.
Choice of static analysis tools and metric extractors. Our selection of code quality metrics and static analysis tools is guided by established software quality frameworks and survey literature. The ISO/IEC 25010 standard defines software product quality along characteristics including maintainability, reliability, and security, all of which are assessed by our selected tools and metrics. Nunez-Varela et al. provide a comprehensive mapping of source code metrics, identifying complexity, size, coupling, and cohesion as the primary measurement dimensions. Our metric selection, comprising cyclomatic complexity (CC), cognitive complexity (Cogn), and non-comment lines of code (NLOC), covers the two most widely adopted dimensions (complexity and size) from their taxonomy.
For static analysis tool selection, we adopted the following criteria: (i) support for at least one of the target programming languages (Python or Java), (ii) configuration independence, to ensure that results are not influenced by project-specific rule sets and to allow fair cross-language comparison, (iii) complementary coverage of different quality dimensions, including complexity, coding style, defects, and security, and (iv) established validation in academic literature, ensuring trustworthiness and recognized effectiveness in code quality assessment research. Based on these criteria, we rely on pylint and flake8 for Python, PMD for Java, SonarCloud and lizard for both languages.
The choice of these static analysis tools is motivated by their ability to provide diverse perspectives on code quality across both languages, hence enhancing the reliability of our analyses. Additionally, these tools are well-established and validated in academic literature, signaling their trustworthiness and established effectiveness in code quality assessment research.
Before moving forward, we excluded CheckStyle from our analysis because its output is highly dependent on user-defined configuration rules, violating criterion (ii) above. Including CheckStyle would have introduced variability attributable to configuration choices rather than to the prompt language effects we aim to measure. This decision is consistent with recent empirical studies on LLM-generated code quality, where CheckStyle was similarly excluded due to its heavy dependence on team-specific style configurations, which could introduce unwanted bias into the interpretation of results.
Additional clarification is required for the SonarCloud metrics. Cognitive Complexity measures code understandability, aligning with developer intuition to identify challenging modules to maintain. Code smells refer to design flaws or implementation patterns that, while not causing immediate failures, increase maintenance difficulty. Examples include code duplication, long methods, complex conditionals, and inconsistent naming. Bugs denote code defects likely to cause incorrect behavior or runtime errors, such as null pointer dereferences, logical flaws, and off-by-one errors.
RQ3 Linguistic Impact on Code Lexicon
Code lexicon in Python code generation. For Python, comments exhibit two contrasting patterns. Chinese and Spanish have a larger proportion of comments in their respective languages than English comments across all models except for GPT in Chinese, where the percentages are similar. Instead, Hindi and Italian predominantly feature English comments across all the models. For literals, a consistent behavior appears among languages and models, with a preference for English literals over those in other languages. Claude shows a higher consistency in using the same language, always showing the lowest values of ‘both’ occurrences. GPT and DeepSeek tend to blend languages when writing comments or literals, showing inconsistency even if in a small portion of cases. A notable difference arises in Italian, where most occurrences do not mix languages, except for GPT with comments.
Code lexicon in Java code generation. For Java, comments reveal a stable trend among languages and models, with a preference for English. Notable exceptions exist in Spanish and Italian with the DeepSeek model, where the proportion of comments in the target language exceeds that of English (Spanish: 15.1% vs. 12.3%; Italian: 11.0% vs. 10.4%), indicating a shift away from the general English-dominant trend. For literals, a notable prevalence of English literals spans across languages and models. As far as cases where comments or literals appear in both (‘b’) languages, Claude shows a better consistency in using the same language than the other LLMs.
For Python, inconsistencies are more prevalent in Chinese and Spanish than in Italian and Hindi, where their occurrence is notably lower. On the LLMs’ side–Claude appears to be the worst of the three models, with the highest percentage of inconsistencies for Chinese and Spanish.
Java, Chinese, and Spanish were confirmed to exhibit more mixups than other languages, with the highest percentage for both GPT and DeepSeek. However, Claude shows an opposite trend to that of Python, exhibiting an almost null percentage of mixed cases.
We found that regardless of the prompt language, LLMs generate identifiers in English, perhaps because of the provided signature, and in particular for Chinese and Hindi, because programming languages do not support such characters to name the identifiers. This is in line with previous work showing how function signatures drive LLMs for generating code summaries. Furthermore, developers tend to write identifiers in English rather than their native language.
We found that–when provided with an Italian method signature, GPT and DeepSeek predominantly produced comments, identifiers, and literals in Italian (with just 2% of literals in English for GPT, and 0% for DeepSeek), with only rare cases of mixed-language identifiers (10% and 8% for GPT and DeepSeek). These exceptions typically involved technical terms that are challenging to translate (e.g., “wrapper,” “directory,” or “output”). Both GPT and DeepSeek consistently generated comments in Italian, with occasional English literals limited to default messages. In contrast, Claude exhibited less consistency, frequently mixing English and Italian for identifiers (58%), while less for literals (2%).
Implications for Practitioners
Our findings suggest specific guidelines: for Python development, Chinese prompts may actually yield higher correctness (RQ1), while for Java, the choice of prompt language should be made with greater caution, as some combinations—particularly Claude with Hindi—exhibit substantially lower compilation rates and functional correctness. Developers should therefore conduct pilot evaluations on a representative sample of their tasks before committing to non-English prompts in production workflows.
The source code quality is not worse. It is just a different code. We found that source code quality indicators do not indicate that code quality, e.g., in terms of maintainability or readability indicators, is necessarily worse. Sometimes, there are precautions to be adopted, e.g., prompts in given languages may lead to strange formatting that requires an (easy) fix. At the same time, the fact that such indicators are significantly different means that code can be implemented by making different choices or by following different strategies. Also, we noticed that the level of documentation (comments) may often differ. We have no means to understand so, but this could be based on what the LLM has observed, e.g., associated with text in given languages. Future work should investigate the reasons for that better.
Our severity-aware analysis (RQ2) reveals an important nuance: while non-English prompts tend to increase the total count of static analysis warnings, these increases are predominantly driven by minor-severity style and formatting issues rather than critical defects. In practice, this means that the additional warnings triggered by non-English prompts are largely addressable through automated formatters (e.g., black for Python, google-java-format for Java) and do not indicate deeper quality degradation. Developers using non-English prompts should therefore incorporate automated formatting as a standard post-generation step.
One cannot assume that the code will be documented in the same language used for the prompt. While, on the one hand, as found in our ablation study, the language used for the signature may drive the identifiers’ language, on the other hand, comments and literals tend to be very inconsistent in general. Therefore, additional work from the developers’ side is needed to ensure their consistency.
This has practical consequences for teams operating in non-English-speaking environments. If consistent documentation in the team’s native language is required, developers should not rely on the LLM’s default behavior. Instead, they should either (i) translate the function signature into the target language, which our ablation study shows significantly increases lexicon consistency for GPT and DeepSeek, or (ii) explicitly instruct the model to use the desired language for comments and identifiers in the system prompt. Even with these measures, post-generation review of comments and literals remains advisable, as no configuration fully guarantees lexicon consistency.


