liveBook · Manning

Pair programming

As explained in Introduction to Generative AI, Second Edition

A software-development practice in which two programmers collaborate closely on the same code.

Pair programming is a collaborative software-development practice in which two programmers work closely on the same code. In AI-assisted versions, one human works with a language model as a programming partner: the developer describes a task in natural language, receives autocomplete-style suggestions, and decides what to keep, revise, or reject. This arrangement is intended to complement human judgment rather than replace it. section 6.6 section 1.7

AI-assisted pair programming commonly supports these activities while retaining important limitations:

  • Suggesting code as a developer types, filling repetitive patterns, offering alternatives, and converting comments or docstrings into code. section 1.7
  • Producing a quick first implementation from a natural-language description, which can make iteration faster, especially for straightforward functions. section 6.6
  • Assisting with testing, coding interviews, and communication for non-native English speakers, while still requiring review because complex tasks can fail. section 1.7 section 6.6
  • Avoiding the assumption that greater autonomy is automatically better: autonomous systems can pursue dead ends for days that a human engineer would recognize quickly. section 1.7
  • Considering security, transparency, and licensing concerns alongside productivity gains. section 1.7

A natural-language function request

A developer writes a comment or docstring describing what a function should do. The model proposes an implementation, and the developer evaluates it before continuing. A generated docstring can also accurately describe a function and its inputs, providing a compact example of the human-model interaction. section 6.6

Figure 6.4 The docstring produced by ChatGPT correctly describes the function given and each input.
A screenshot of a computer

AI-generated content may be incorrect.

Inspect the generated docstring example to see how an AI programming partner can describe a function and its inputs. section 6.6

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Explains autocomplete, natural-language requests, iteration, and limitations, but defers detailed treatment of newer agentic tools.
Examples
Uses Copilot suggestions, comment-to-code conversion, testing assistance, and a generated function docstring as examples.
What it assumes
Assumes a developer can describe programming tasks and evaluate generated code, while supporting users with different expertise levels.
What you can do after
Apply via AI coding assistants to draft, complete, test, and iteratively revise code while checking proposed results.
How it connects
Connects pair programming with code generation, large language models, GitHub Copilot, and autonomous software agents.

Also explained in

Compare how 5 books explain pair programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.