arXiv:2506.08790cs.SEcs.AI2025-06被引 13

测试三大AI编程工具生成代码的环保性,发现默认行为不绿色。

Do Generative AI Tools Ensure Green Code? An Investigative Study

  • 对比ChatGPT、BARD、Copilot生成代码的可持续实践
  • 多数场景下生成代码违反绿色编码规则
  • 提醒开发者需主动优化,适合关注代码环保的程序员

软件可持续性正成为关键议题,旨在优化资源利用、降低环境影响,构建更绿色、更具韧性的数字生态。软件的“绿色度”通常由是否采用可持续编码实践决定。随着生成式AI生态日益成熟,越来越多开发者使用自然语言提示让AI生成代码。然而,关于AI生成代码可持续性的研究仍严重不足。本文首次对三种主流生成式AI工具——ChatGPT、BARD和Copilot——生成代码的可持续性进行了初步调查。结果表明,在多种规则与场景下,这些工具默认生成的代码表现出非绿色行为,凸显了开展深入研究与制定有效修复策略的紧迫性。

原文摘要 · Abstract (English)

Software sustainability is emerging as a primary concern, aiming to optimize resource utilization, minimize environmental impact, and promote a greener, more resilient digital ecosystem. The sustainability or "greenness" of software is typically determined by the adoption of sustainable coding practices. With a maturing ecosystem around generative AI, many software developers now rely on these tools to generate code using natural language prompts. Despite their potential advantages, there is a significant lack of studies on the sustainability aspects of AI-generated code. Specifically, how environmentally friendly is the AI-generated code based upon its adoption of sustainable coding practices? In this paper, we present the results of an early investigation into the sustainability aspects of AI-generated code across three popular generative AI tools - ChatGPT, BARD, and Copilot. The results highlight the default non-green behavior of tools for generating code, across multiple rules and scenarios. It underscores the need for further in-depth investigations and effective remediation strategies.

AI编程代码可持续性绿色计算

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。