On the "Naturalness" of Buggy Code
Not on the map. Why?
Abstract (arXiv)
Real software, the kind working programmers produce by the kLOC to solve real-world problems, tends to be "natural", like speech or natural language; it tends to be highly repetitive and predictable. Researchers have captured this naturalness of software through statistical models and used them to good effect in suggestion engines, porting tools, coding standards checkers, and idiom miners. This suggests that code that appears improbable, or surprising, to a good statistical language model is "unnatural" in some sense, and thus possibly suspicious. In this paper, we investigate this hypothesis. We consider a large corpus of bug fix commits (ca.~8,296), from 10 different Java projects, and we focus on its language statistics, evaluating the naturalness of buggy code and the corresponding fixes. We find that code with bugs tends to be more entropic (i.e., unnatural), becoming less so as bugs are fixed. Focusing on highly entropic lines is similar in cost-effectiveness to some well-known static bug finders (PMD, FindBugs) and ordering warnings from these bug finders using an entropy measure improves the cost-effectiveness of inspecting code implicated in warnings. This suggests that entropy may be a valid language-independent and simple way to complement the effectiveness of PMD or FindBugs, and that search-based bug-fixing methods may benefit from using entropy both for fault-localization and searching for fixes.
Key facts. Cited by 35 papers in the map (data through 7 Oct 2026). First posted on arXiv 3 Jun 2015.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2021: 9; 2022: 4; 2023: 4; 2024: 4; 2025: 11; 2026: 3.
35 papers.
Sort:
By area:
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
- 2023Large Language Models for Test-Free Fault Localizationcited by 67
- 2021Self-Supervised Bug Detection and Repaircited by 59
- 2022NatGen: Generative pre-training by "Naturalizing" source codecited by 53
- 2021On Multi-Modal Learning of Editing Source Codecited by 25
- 2025EpiCoder: Encompassing Diversity and Complexity in Code Generationcited by 21
- 2021Understanding Neural Code Intelligence Through Program Simplificationcited by 20
- 2025Can LLMs Reason About Program Semantics? A Comprehensive Evaluation of LLMs on Formal Specification Inferencecited by 14
- 2023Toward a Theory of Causation for Interpreting Neural Code Modelscited by 12
- 2025Exploring Code Language Models for Automated HLS-based Hardware Generation: Benchmark, Infrastructure and Analysiscited by 10
23 more
- 2022Detect-Localize-Repair: A Unified Framework for Learning to Debug with CodeT5cited by 9
- 2022Towards a consistent interpretation of AIOps modelscited by 8
- 2021Variable Name Recovery in Decompiled Binary Code using Constrained Masked Language Modelingcited by 7
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testingcited by 5
- 2024Leveraging Reviewer Experience in Code Review Comment Generationcited by 4
- 2025ObscuraCoder: Powering Efficient Code LM Pre-Training Via Obfuscation Groundingcited by 4
- 2021Learning to Extend Program Graphs to Work-in-Progress Codecited by 3
- 2024Assessing the Latent Automated Program Repair Capabilities of Large Language Models using Round-Trip Translationcited by 3
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalnesscited by 3
- 2025Aligning Crowd-sourced Human Feedback for Reinforcement Learning on Code Generation by Large Language Modelscited by 3
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completioncited by 3
- 2022Leveraging Structural Properties of Source Code Graphs for Just-In-Time Bug Predictioncited by 2
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 2
- 2025Deep Learning-Based Identification of Inconsistent Method Names: How Far Are We?cited by 2
- 2025Deep Learning-based Intrusion Detection Systems: A Surveycited by 2
- 2026Code for Machines, Not Just Humans: Quantifying AI-Friendliness with Code Health Metricscited by 2
- 2024ANVIL: Anomaly-based Vulnerability Identification without Labelled Training Datacited by 1
- 2025Bringing Structure to Naturalness: On the Naturalness of ASTscited by 1
- 2025Empirical Study of Code Large Language Models for Binary Security Patch Detectioncited by 1
- 2021Embedding Code Contexts for Cryptographic API Suggestion:New Methodologies and Comparisonscited by 0
- 2021DeepMutants: Training neural bug detectors with contextual mutationscited by 0
- 2026Prompt Coverage Adequacycited by 0
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Codecited by 0
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Code11 Sep 2026
- 2026Prompt Coverage Adequacy2 Jul 2026
- 2026Code for Machines, Not Just Humans: Quantifying AI-Friendliness with Code Health Metrics5 Jan 2026
- 2025Empirical Study of Code Large Language Models for Binary Security Patch Detection7 Sep 2025
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion22 Aug 2025
- 2025Bringing Structure to Naturalness: On the Naturalness of ASTs11 Apr 2025
- 2025Deep Learning-based Intrusion Detection Systems: A Survey10 Apr 2025
- 2025ObscuraCoder: Powering Efficient Code LM Pre-Training Via Obfuscation Grounding27 Mar 2025
- 2025Aligning Crowd-sourced Human Feedback for Reinforcement Learning on Code Generation by Large Language Models19 Mar 2025
- 2025Can LLMs Reason About Program Semantics? A Comprehensive Evaluation of LLMs on Formal Specification Inference22 Feb 2025
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalness20 Feb 2025
- 2025Exploring Code Language Models for Automated HLS-based Hardware Generation: Benchmark, Infrastructure and Analysis19 Feb 2025
23 more
- 2025Deep Learning-Based Identification of Inconsistent Method Names: How Far Are We?22 Jan 2025
- 2025EpiCoder: Encompassing Diversity and Complexity in Code Generation8 Jan 2025
- 2024Leveraging Reviewer Experience in Code Review Comment Generation17 Sep 2024
- 2024ANVIL: Anomaly-based Vulnerability Identification without Labelled Training Data28 Aug 2024
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testing19 Feb 2024
- 2024Assessing the Latent Automated Program Repair Capabilities of Large Language Models using Round-Trip Translation15 Jan 2024
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformers8 Dec 2023
- 2023Large Language Models for Test-Free Fault Localization3 Oct 2023
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPT1 Apr 2023
- 2023Toward a Theory of Causation for Interpreting Neural Code Models7 Feb 2023
- 2022Detect-Localize-Repair: A Unified Framework for Learning to Debug with CodeT527 Nov 2022
- 2022NatGen: Generative pre-training by "Naturalizing" source code15 Jun 2022
- 2022Towards a consistent interpretation of AIOps models4 Feb 2022
- 2022Leveraging Structural Properties of Source Code Graphs for Just-In-Time Bug Prediction25 Jan 2022
- 2021On Multi-Modal Learning of Editing Source Code15 Aug 2021
- 2021DeepMutants: Training neural bug detectors with contextual mutations14 Jul 2021
- 2021Understanding Neural Code Intelligence Through Program Simplification7 Jun 2021
- 2021Learning to Extend Program Graphs to Work-in-Progress Code28 May 2021
- 2021Self-Supervised Bug Detection and Repair26 May 2021
- 2021Variable Name Recovery in Decompiled Binary Code using Constrained Masked Language Modeling23 Mar 2021
- 2021Embedding Code Contexts for Cryptographic API Suggestion:New Methodologies and Comparisons15 Mar 2021
- 2021Unified Pre-training for Program Understanding and Generation10 Mar 2021
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generation9 Feb 2021
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
- 2023Large Language Models for Test-Free Fault Localizationcited by 67
- 2021Self-Supervised Bug Detection and Repaircited by 59
- 2022NatGen: Generative pre-training by "Naturalizing" source codecited by 53
- 2021On Multi-Modal Learning of Editing Source Codecited by 25
- 2025EpiCoder: Encompassing Diversity and Complexity in Code Generationcited by 21
- 2021Understanding Neural Code Intelligence Through Program Simplificationcited by 20
- 2023Toward a Theory of Causation for Interpreting Neural Code Modelscited by 12
- 2025Exploring Code Language Models for Automated HLS-based Hardware Generation: Benchmark, Infrastructure and Analysiscited by 10
- 2022Detect-Localize-Repair: A Unified Framework for Learning to Debug with CodeT5cited by 9
12 most cited of 31 All 31 (JSON)
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Code11 Sep 2026
- 2026Prompt Coverage Adequacy2 Jul 2026
- 2025Empirical Study of Code Large Language Models for Binary Security Patch Detection7 Sep 2025
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion22 Aug 2025
- 2025Bringing Structure to Naturalness: On the Naturalness of ASTs11 Apr 2025
- 2025Deep Learning-based Intrusion Detection Systems: A Survey10 Apr 2025
- 2025ObscuraCoder: Powering Efficient Code LM Pre-Training Via Obfuscation Grounding27 Mar 2025
- 2025Exploring Code Language Models for Automated HLS-based Hardware Generation: Benchmark, Infrastructure and Analysis19 Feb 2025
- 2025Deep Learning-Based Identification of Inconsistent Method Names: How Far Are We?22 Jan 2025
- 2025EpiCoder: Encompassing Diversity and Complexity in Code Generation8 Jan 2025
- 2024Leveraging Reviewer Experience in Code Review Comment Generation17 Sep 2024
- 2024ANVIL: Anomaly-based Vulnerability Identification without Labelled Training Data28 Aug 2024
12 newest of 31 All 31 (JSON)