GitHub Copilot AI pair programmer: Asset or Liability?

Arghavan Moradi Dakhel, Vahid Majdinasab, Amin Nikanjam, Foutse Khomh, Michel C. Desmarais, Zhen Ming, JiangarXiv 2022

TL;DR

GitHub Copilot is a powerful "AI pair programmer," but is it a net positive for codebases? This study finds that while Copilot excels at generating textbook algorithms, it often struggles with complex constraints and produces less diverse, less correct code than human students. However, its buggy solutions are significantly easier and faster to repair than human-written ones, making it a potent asset for experts but a potential liability for novices who lack the skill to filter its output.

What Problem Does This Paper Address?

The dream of automatic program synthesis—having a machine write code from a description—is becoming a reality with Large Language Models (LLMs) like OpenAI’s Codex, which powers GitHub Copilot. While early research focused heavily on whether these models could produce correct code, this paper digs deeper into the quality and utility of that code.

The authors address a critical gap: How does Copilot compare to human programmers in terms of code complexity, diversity, and the effort required to fix bugs? They also investigate whether Copilot can reliably reproduce its own "correct" answers over time and whether it truly understands fundamental computer science algorithms or is simply reciting memorized patterns.

Methods

The researchers employed two distinct evaluation pipelines to stress-test Copilot:

  1. Textbook Algorithm Analysis: They selected fundamental problems (sorting, binary search trees, graphs, and greedy algorithms) from the classic Introduction to Algorithms (CLRS). To avoid the "memorization" issue—where the model simply spits out code it saw during training—the authors performed "prompt engineering," summarizing problem descriptions in their own words and cross-validating them for clarity.
  2. Human vs. AI Comparison: They compared Copilot’s output against a dataset of thousands of Python submissions from actual students.

To evaluate these pipelines, they used a mix of standard and novel metrics:

  • Correctness & Optimality: Does the code pass unit tests, and is it computationally efficient?
  • Reproducibility: Does Copilot give the same correct answer across different attempts and over a 30-day window?
  • Repair Cost: Using an automated tool called Refactory, they measured how much effort (time and code changes) was needed to fix buggy solutions.
  • Diversity & Complexity: They used Abstract Syntax Tree (AST) similarity to see how "novel" the solutions were and Cyclomatic Complexity to measure how easy the code is to understand.
Figure 1: The Workflow of proposed methods. The study includes two different methods to test Copilot in recommending codes to solve programming problems. The first pipeline focuses on algorithmic problems collected from a well-known algorithm design book [11]. The second pipeline focuses on the assignments of a Python programming course [28]. It compares Copilot with students in solving programming problems in different aspects.

Datasets

  • Fundamental Algorithmic Problems: A curated set of problems based on the Introduction to Algorithms textbook, covering 4 categories: Sorting, Data Structures (BST), Graph Algorithms, and Greedy Algorithms.
  • Python Programming Course Dataset: A collection of 2,442 "Correct" and 1,783 "Buggy" student submissions for five specific Python tasks (e.g., sequential search, duplicate elimination).

Key Insights and Ideas

  • The "Expert Filter" Requirement: Copilot is a "force multiplier" for experts. Because its buggy code is often very close to the correct solution (high BLEU score similarity), an expert can fix it in seconds. A novice, however, might accept a subtly buggy or non-optimal solution they don't fully understand.
  • Prompt Sensitivity: Copilot struggles with natural language nuances that humans find trivial. For example, it failed to sort tuples correctly when asked to put "older people at the front," but succeeded when the prompt was changed to the technical term "descending order."
  • Lack of Diversity: While humans solve problems in a myriad of creative (and sometimes messy) ways, Copilot tends to converge on a few specific patterns. It often relies on built-in functions (like sort()) even when explicitly asked not to use them.
  • The "Snowball Effect" in Complexity: Copilot struggles to combine multiple methods. If it generates a buggy base class, that bug propagates through every subsequent method it suggests, leading to a total failure of the larger programming task.

Key Results

  • Correctness: Humans outperformed Copilot. The average Correct Ratio (CR) for students was 0.59, while Copilot’s CR at its Top10 suggestions was only 0.35.
  • Repairability: Copilot’s bugs are "cheaper." The average repair time for a Copilot bug was 4.94 seconds compared to 6.48 seconds for students. Furthermore, 95% of Copilot’s bugs were fixable by automated tools, vs. 89% for humans.
  • Complexity: Copilot generally produces simpler code. Its average Cyclomatic Complexity was 2.81, significantly lower than the students' 3.87, suggesting its solutions are often more readable (if they are correct).
  • Reproducibility: Copilot is inconsistent. Correct solutions were not exactly reproduced in the majority of sorting tasks over a 30-day period, though the suggested codes remained structurally similar.

Limitations and Future Work

The study acknowledges that Copilot is a "black box"—because it is closed-source, it's impossible to know exactly why its behavior changes over time or if it has simply memorized certain solutions. Additionally, the tasks used (textbook algorithms and intro programming assignments) may not fully represent the complexity of professional, industrial-scale software engineering.

The authors suggest that future work should focus on building a "filtering layer" on top of Copilot to automatically catch and remove buggy or non-optimal suggestions before they reach the developer. They also call for more human-centered studies to see how developers of different skill levels interact with the tool in real-time.

Summary updated

BibTeX
@misc{dakhel2022github,
  author = {Arghavan Moradi Dakhel and Vahid Majdinasab and Amin Nikanjam and Foutse Khomh and Michel C. Desmarais and Zhen Ming and Jiang},
  title = {{GitHub Copilot AI pair programmer: Asset or Liability?}},
  year = {2022},
  eprint = {2206.15331},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.15331},
}
Figure