Quality of AI-Generated vs. Human-Generated Code
Tasneem Muhammed Eltabakh, Nada Nabil Soudi, Doaa Shawky · 2024
This study examines the quality differences between AI-generated and human-generated code through an evaluation of multiple software quality metrics, including maintainability, complexity, and documentation. Using a dataset of 5,312 code samples—2,700 human-generated and 2,612 AI-generated—we applied machine learning techniques to classify and analyze the code based on these metrics. The results revealed that AI-generated code tends to excel in maintainability and documentation, demonstrating higher maintainability index scores and a higher ratio of comments. Additionally, AI-generated code often features simpler control structures, reflected in its lower cyclomatic complexity. In contrast, human-generated code showcased greater adaptability and flexibility, particularly in addressing complex problem statements. A neural network classifier achieved 88.05% accuracy in distinguishing between the two code origins, with comments ratio, maintainability index, and cyclomatic complexity being the most significant differentiators. These findings highlight the complementary roles of AI and human contributions in software development, suggesting strategic integration of both for enhanced efficiency and quality.