Abstract
Developers frequently simplify code to reduce complexity and improve maintainability while preserving functionality. However, manual simplification is time-consuming and error-prone. While existing automated approaches like delta debugging (deletion-based) or refactoring (rule-based) exist, their effectiveness in mimicking real-world developer behavior remains unstudied. This paper presents the first comprehensive study of developer-induced program simplification in Open-source Software (OSS), revealing a significant gap between human practices and current automation. We introduce SimpT5, a deep-learning-based tool trained on a novel dataset of 92,485 simplified programs. SimpT5 leverages simplified line localization and a validation checker to produce high-quality, semantically equivalent code. Our evaluation demonstrates that SimpT5 significantly outperforms prior methods, achieving a 30.45% exact match rate with human-written simplifications.
Introduction
As software systems evolve, they often accumulate "code bloat"—unnecessary complexity that hinders readability and maintenance. To combat this, developers perform "developer-induced program simplification," rewriting code to be more concise while keeping its behavior exactly the same.
The challenge lies in automating this process. Current tools generally fall into two categories: deletion-based (like delta debugging), which are excellent at removing dead code but cannot "rewrite" logic, and rule-based (like refactoring engines), which are often too rigid to capture the creative ways humans condense code using modern language features. This research bridges the gap by studying human simplification patterns and building a generative model that mimics them.
Empirical Study and Taxonomy
To understand the "how" and "why" of human code simplification, the researchers manually analyzed 382 pull requests from 296 OSS Java projects. This study resulted in a comprehensive taxonomy of 26 distinct transformation types categorized into seven groups: control logic, extraction, deletion, API usage, inline code, lambda expressions, and others.
A key finding was the "Refactoring Gap": existing tools like RefactoringMiner failed to detect 30% of the simplifications developers actually made. This occurs because humans often interleave multiple changes—such as replacing a loop with a stream while simultaneously inlining a variable—which confuses rule-based systems. Furthermore, pure deletions accounted for only 16.5% of the transformations, proving that "simplification" is much more than just hitting the backspace key.
SimpT5: A Generative Approach
Inspired by these findings, the authors developed SimpT5, a tool built upon the CodeT5 architecture. Unlike generic language models, SimpT5 is specifically tuned for the constraints of program simplification.
The SimpT5 pipeline consists of three integrated stages:
- Training Stage: The model is trained on SimpliBench, a massive new dataset of 92,485 original-simplified method pairs. It utilizes "Simplified Line Localization," a technique that marks exactly which lines in the original code were modified in the ground truth. This "nudge" helps the model focus its attention on the parts of the code that require a makeover.
- Inference Stage: SimpT5 generates candidate simplified versions of a given method using hard prompts (e.g., "Simplify this Java method").
- Validation Stage: To ensure the generated code isn't just shorter but actually correct, a checker verifies that the code compiles and passes the project's existing test suite, ensuring functional equivalence.
Datasets: SimpliBench
The researchers introduced SimpliBench to provide a high-quality benchmark for this task. It includes:
- The "Whole" Dataset: 92,485 pairs mined from over 25,000 GitHub projects for broad training.
- The "Valid" Dataset: A curated subset of 404 pairs where the code is fully compilable and has a robust test suite. This ensures that the ground-truth simplifications are verified for semantic equivalence.
Key Results and Insights
SimpT5 represents a significant advancement over prior state-of-the-art models like TufanoNMT and AutoTransform.
- Accuracy: SimpT5 achieved a 30.45% exact match rate on the Valid dataset. For context, previous models struggled to achieve any perfect matches on this specific task.
- Localization Power: Providing line-level hints (Line Localization) doubled the "Perfect Prediction" rate from 15% to 30%.
- Human-Like Diversity: SimpT5 successfully utilized 14 different types of transformations, including complex API replacements and lambda conversions, whereas traditional tools are often limited to one or two types.
- Code Quality: On average, SimpT5 reduced Source Lines of Code (SLOC) by 18.13% while lowering both Cyclomatic and Cognitive complexity.
Conclusion
By moving beyond simple deletions and rigid rules, SimpT5 demonstrates that deep learning can effectively capture the nuances of human code simplification. The study highlights that effective automation requires a generative approach capable of diverse transformations, backed by a rigorous validation framework. Future work will focus on expanding SimpT5 to other programming languages and integrating it into IDEs to provide real-time "Quick Fix" suggestions for developers.
Summary updated