An exploratory study on just-in-time multi-programming-language bug prediction

Zengyang Li, Jiabao Ji, Peng Liang, Ran Mo, Hui Liu

Introduction

Modern software development is increasingly a polyglot endeavor. To balance performance, flexibility, and ecosystem compatibility, large-scale systems often utilize multiple programming languages—for instance, combining a Java-based backend with a C++ performance layer or Python-based data processing scripts. However, this architectural diversity introduces a unique challenge: Multi-Programming-Language Bugs (MPLBs). These are defects whose resolution requires modifications across language boundaries. MPLBs are notoriously more complex, harder to diagnose, and more time-consuming to resolve than single-language bugs.

Traditional bug prediction techniques often occur late in the software development lifecycle, leading to high maintenance costs. Just-in-Time (JIT) bug prediction aims to mitigate this by identifying bug-inducing changes at the moment a developer commits code. While JIT prediction has been studied extensively for single-language environments, this paper presents the first exploratory study specifically targeting JIT prediction for MPLBs.

Methodology

The researchers developed a comprehensive JIT MPLB prediction framework designed to evaluate the effectiveness of machine learning in identifying cross-language defects. The study utilized four common machine learning classifiers: Support Vector Machines (SVM), Logistic Regression (LR), Decision Trees (DT), and Random Forest (RF).

Feature Engineering

To train these models, the authors extracted 23 distinct metrics for every commit, categorized into two primary groups:

  1. General Commit Metrics (Category 1): These represent standard software engineering measures, such as the total lines of code (LOC) added or deleted, and the experience level of the author.
  2. MPL-Specific Metrics (Category 2): These are novel metrics designed to capture the complexity of multi-language changes. They include the number of different languages modified in a single commit, the entropy of the languages involved, and Delta Maintainability Model (DMM) scores.

To establish the ground truth for the dataset, the authors employed the SZZ algorithm, a standard industry technique that traces bug-fixing commits back to the specific historical changes that originally introduced the defect.

Experimental Setup

The study is grounded in a newly constructed dataset derived from 18 large-scale Apache open-source projects. Notable projects in the dataset include Kafka, ZooKeeper, and CloudStack. The selection criteria ensured that projects were sufficiently mature, possessing at least two languages, over 1,000 commits, and a documented history of bug-inducing changes. The scale of these projects varied significantly, ranging from 380,000 to over 44 million lines of code, providing a diverse testing ground for the prediction models.

Key Findings

1. Model Performance

The Random Forest (RF) classifier emerged as the most effective model, consistently outperforming SVM, LR, and DT. The RF models achieved an average Area Under the Curve (AUC) of 76.13%, with precision and recall metrics both reaching approximately 75-76%. The ensemble nature of Random Forest appears particularly well-suited to navigating the non-linear relationships between complex commit metrics and the introduction of multi-language bugs.

2. The Dominance of Size Metrics

Despite the introduction of sophisticated MPL-specific metrics, the study found that traditional "size" metrics remain the most potent predictors. Specifically, C3 (Changed LOC of all files) was identified as the most crucial metric across nearly all studied projects. This suggests that even in complex polyglot environments, the sheer volume of change in a commit remains the primary indicator of risk.

3. Model Simplification (The 40% Rule)

One of the most practical insights for developers is that high-accuracy prediction does not require an exhaustive list of metrics. The researchers found that using only the top 9 metrics (roughly 40% of the total feature set) achieved nearly the same performance (~75% AUC) as the full 23-metric model. This negligible 1% drop in performance suggests that practitioners can implement "lean" prediction tools that offer high efficiency with low computational overhead.

4. Cross-Project Feasibility

Predicting bugs in one project using a model trained on a different project remains a challenge, yielding an average AUC of 62%. However, the study found that training a model on a combined dataset of multiple projects boosted performance to 66% AUC. This indicates that while project-specific nuances exist, there are underlying "global" bug patterns common to multi-language software systems.

Limitations and Future Directions

While the study provides a strong foundation for JIT MPLB prediction, several areas for improvement remain:

  • Tooling: The study relied on the Lizard tool for code analysis. While it supports 18 major languages, it does not cover every language (e.g., Perl), potentially leading to data gaps in specific projects.
  • Scope: The research focused exclusively on the Apache ecosystem. Future studies could investigate whether commercial, closed-source software exhibits different multi-language bug patterns.
  • Granularity: The current framework operates at the commit level. Future work could refine this to the function or class level to provide developers with more granular, actionable feedback.
  • Language Pairings: There is significant interest in exploring whether specific language combinations (e.g., Java and C++ versus Java and Python) are more prone to specific types of cross-language defects.

Conclusion

This exploratory study demonstrates that JIT prediction for multi-programming-language bugs is not only feasible but highly effective. By leveraging Random Forest models and a streamlined set of commit metrics, development teams can identify high-risk cross-language changes at the moment of creation, significantly reducing the long-term complexity and cost of software maintenance.

Summary updated

BibTeX
@article{li2024exploratory,
  author = {Zengyang Li and Jiabao Ji and Peng Liang and Ran Mo and Hui Liu},
  title = {{An exploratory study on just-in-time multi-programming-language bug prediction}},
  journal = {Inf. Softw. Technol.},
  year = {2024},
  doi = {10.1016/j.infsof.2024.107524},
}
Figure