Lune

OOPSLA2024Top-tier venue

Dependency-Aware Code Naturalness

Chen Yang, Junjie Chen, Jiajun Jiang, Yuliang Huang

Abstract

Code naturalness, which captures repetitiveness and predictability in programming languages, has proven valuable for various code-related tasks in software engineering. However, precisely measuring code naturalness remains a fundamental challenge. Existing methods measure code naturalness over individual lines of code while ignoring the deep semantic relations among different lines, e.g., program dependency, which may negatively affect the precision of the measure. Despite the intuitive appeal of extending the code naturalness measure to the code dependency domain (as there are some work that have initiated the utilization of code dependency for diverse code-related tasks), this assumption remains unexplored and warrants direct investigation. In this study, we aim to perform the first empirical study to investigate whether incorporating code dependency, instead of analyzing individual lines, can enhance the precision of measuring code naturalness.

To achieve that, we first propose a new method named DAN for measuring code naturalness by incorporating the rich dependency information in the code. Specifically, DAN extracts multiple sequences of code lines by traversing the program dependency graph, where different code lines are connected by dependencies in each sequence, and then the code naturalness will be measured by taking each sequence as a whole. In this way, the dependency information can be well captured. Finally, we have conducted an extensive study to evaluate the influence of code dependency for measuring code naturalness with DAN, and compared it with the state-of-the-art methods under three emerging application scenarios of code naturalness. The results demonstrate that DAN can not only better distinguish natural and unnatural code, but also substantially boost two important downstream applications of code naturalness, i.e., distinguishing buggy and non-buggy code lines and data cleansing for training better code models, reflecting the significance of code dependency in measuring code naturalness.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models cites Clarifying Semantics of In-Context Examples for Unit Test Generation
  • Clarifying Semantics of In-Context Examples for Unit Test Generation cites Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models
  • Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper) cites Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models
  • Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper) cites Clarifying Semantics of In-Context Examples for Unit Test Generation
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. Fuzzing MLIR Compiler Infrastructure via Operation Dependency AnalysisChenyao Suo, Junjie Chen, Shuang Liu, Jiajun Jiang et al.ISSTA 2024 · 12 citations
  2. Reflective Unit Test Generation for Precise Type Error Detection with Large Language ModelsChen Yang, Ziqi Wang, Yanjie Jiang, Lin Yang et al.ASE 2025 · 1 citation
  3. Clarifying Semantics of In-Context Examples for Unit Test GenerationChen Yang, Lin Yang, Ziqi Wang, Dong Wang et al.ASE 2025 · 1 citation
  4. Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper)Chen Yang, Junjie ChenISSTA 2026

Builds on16

  1. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  2. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
  3. CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 citations
  4. CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement LearningHung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese et al.NeurIPS 2022 · 571 citations
  5. CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu et al.ICLR 2023 · 234 citations

Related papers

  1. Do bugs lead to unnaturalness of source code?Yanjie Jiang, Hui Liu, Yuxia Zhang, Weixing Ji et al.FSE 2022 · 8 citations
  2. Has My Code Been Stolen for Model Training? A Naturalness Based Approach to Code Contamination DetectionHaris Ali Khan, Yanjie Jiang, Qasim Umer, Yuxia Zhang et al.FSE 2025 · 1 citation
  3. Beyond Sequences: Two-dimensional Representation and Dependency Encoding for Code GenerationXiangyu Zhang, Yu Zhou, Guang Yang, Wei Cheng et al.ACL 2025
  4. CrystalBLEU: Precisely and Efficiently Measuring the Similarity of CodeAryaz Eghbali, Michael PradelASE 2022 · 33 citations
  5. Contextuality of Code Representation LearningYi Li, Shaohua Wang, Tien N. NguyenASE 2023 · 2 citations
Dusk over the sea between two cliffs drawn in fine vertical lines