The rise of AI coding assistants has sparked a debate in the software engineering world: is the code these agents produce destined to be quickly discarded, a sort of 'disposable' contribution that creates more maintenance burden than it solves? New research challenges this narrative, revealing surprising insights about the longevity and quality of AI-generated code in open-source projects. But it’s not all good news, as AI introduces its own set of unique challenges.

AI Code Survives Longer, But Why?

A groundbreaking study published on arXiv.org, titled "Will It Survive? Deciphering the Fate of AI-Generated Code in Open Source," analyzed over 200,000 code units in 201 open-source projects. Dr. Patel here! What was most fascinating to me is that, contrary to the prevailing disposable code hypothesis, AI-authored code demonstrated a significantly longer lifespan than code written by humans. Specifically, the research found a 15.8 percentage-point lower modification rate at the line level and a 16% lower hazard of modification (HR = 0.842, p < 0.001).

However, the study also revealed nuanced differences in how AI and human-authored code are modified. AI-generated code showed a slightly higher rate of corrective modifications (26.3% vs. 23.0%), suggesting that while AI code may be more robust overall, it might require more fine-tuning to fix errors. Human-authored code, on the other hand, had higher adaptive modification rates, indicating a greater tendency to evolve and adapt to changing requirements. The researchers note that predicting when modifications occur is difficult, indicating that organizational and external factors play a crucial role.

Build Systems: A New Frontier for AI-Generated Code

While the "Will It Survive?" study focused on general source code, another paper, "AI builds, We Analyze: An Empirical Study of AI-Generated Build Code Quality," delves into the often-overlooked realm of build systems. Build systems are critical for automating the process of compiling, testing, and packaging software. According to this research, AI agents are increasingly being used to generate build code, but the quality and maintainability of this code are still largely unknown.

The researchers behind this second paper leveraged AIDev, a large-scale dataset of agent-authored pull requests (Agentic-PRs) from real-world GitHub repositories. Their analysis identified 364 maintainability and security-related build smells across varying severity levels in AI-generated build code. These smells include issues such as a lack of error handling and hardcoded paths or URLs. However, the study also found that AI agents can sometimes remove existing code smells through refactoring. "More than 61% of Agentic-PRs are approved and merged with minimal human intervention," the study authors write. This highlights a complex dynamic where AI can both introduce and resolve code quality issues in build systems.

"More than 61% of Agentic-PRs are approved and merged with minimal human intervention."

— arXiv.org

The Future of AI in Software Development

These findings have significant implications for how organizations approach the integration of AI coding assistants. While the initial fear was that AI-generated code would be a short-term fix leading to long-term maintenance headaches, the data suggests otherwise. AI-generated code can be surprisingly durable and effective, particularly at the line level. However, it's clear that AI is not a perfect replacement for human developers. The slightly elevated corrective rates in AI code, coupled with the potential for introducing build smells, underscores the need for careful oversight and quality assurance. We're seeing that the bottleneck is not necessarily the quality of the generated code, but the organizational practices that govern its evolution. As AI continues to evolve, the focus should shift from simply generating code to developing strategies for managing and maintaining it effectively. Organizations need to develop AI-aware build code quality assessments to guide and govern AI-generated build systems code and to best leverage the strengths of both human and artificial intelligence in software development.