Prompts Are Programs Too! Understanding How Developers Build Software Containing Prompts

Jenny T. Liang, Melissa Lin, Nikitha Rao, Brad A. Myers

TL;DR

This paper argues that natural language prompts used with Foundation Models (FMs) are essentially programs, a concept they term "prompt programming." Through interviews with 20 developers, they reveal that prompt programming is a distinct, iterative, and often unsystematic process that differs significantly from traditional software development, highlighting challenges in understanding FM behavior and developing reliable mental models.

What Problem Does This Paper Address?

The rapid rise of generative AI, powered by Foundation Models (FMs) like GPT-4, has led to the widespread use of natural language prompts to control software features. This practice, known as "prompt engineering," is becoming a crucial part of software development, enabling new intelligent functionalities. However, despite the growing impact of prompt-powered software, there's a significant knowledge gap regarding the development process of these prompts and how it relates to traditional programming. The authors aim to bridge this gap by exploring "prompt programming" as a distinct phenomenon, understanding how developers create software that incorporates these natural language instructions.

Methods

The researchers employed a Straussian grounded theory methodology to explore the phenomenon of prompt programming. This qualitative approach involves:

  • Defining a research question: How do programmers develop programs that incorporate natural language prompts?
  • Developing theoretical sensitivity: Building an intuition for the phenomenon through prior literature and domain expertise.
  • Generating a grounded theory: Conducting semi-structured interviews with 20 developers who create prompt programs. Data collection and analysis were simultaneous, involving line-by-line coding, axial coding, and memo creation to develop categories and a theory.
  • Triangulating with literature: Comparing findings with existing research in NLP, HCI, and software engineering.
  • Validating the grounded theory: Seeking feedback from study participants and an external researcher to ensure the theory's fit and credibility.

They also used maximum variation sampling to ensure a diverse participant pool across various models, domains, and prompt structures.

Datasets

The paper does not explicitly mention the use of specific datasets for training or evaluation in the context of the study itself. Instead, the research focuses on understanding the process of prompt programming through developer interviews. The participants, however, discussed the importance of curating diverse and representative datasets for their prompt programs, especially for few-shot learning and evaluating performance.

Key Insights and Ideas

  • Prompts as Programs: The core idea is that prompts, when used to control FM behavior for specific tasks with variable inputs, function as programs. This reframes prompt engineering as a form of programming.
  • Mental Models of FMs, Not Code: Unlike traditional developers who build mental models of code, prompt programmers develop mental models of the FM's behavior by interacting with it. This is a fundamental shift in how developers reason about their creations.
  • Unreliable Mental Models: Despite extensive iteration and experience, prompt programmers struggle to develop reliable mental models of FM behavior. This contrasts with the well-formed mental models typically found in expert traditional programmers.
  • Rapid and Unsystematic Development: Prompt programming is characterized by a rapid, trial-and-error, and often unsystematic development process, driven by the need to experiment with prompts and observe FM outputs.
  • Fragile Prompts: Prompts are highly sensitive to minute details and can be "finicky" and "fragile," meaning small changes can drastically alter their performance, often requiring significant re-evaluation.
  • Data Curation is Central: Unlike traditional software development, data curation becomes a critical activity for prompt programming, essential for evaluating prompts and providing examples.

Key Results

The study identified 15 observations categorized into four types of barriers in prompt programming: understanding FM behavior, dealing with stochasticity, programming in natural language, and testing prompt program behavior.

  • Programmer: Developers must build mental models of FM behavior (#1), but these models are often unreliable (#2). They rely on external knowledge and prior experience (#3).
  • Foundation Model: Each FM has unique qualities and capabilities that influence prompt writing (#4).
  • Prompt: Minute details matter significantly, making prompts finicky and fragile (#5, #6).
  • Requirements: Requirements are expressed within the prompt and can evolve as FM capabilities are discovered (#7, #8).
  • Design: Prompts can be decomposed and chained, but dependent prompts are tightly coupled (#9, #10).
  • Implementation: Prompt programming is rapid and unsystematic (#11).
  • Debugging: Fault localization is difficult and unsystematic (#12).
  • Data Curation: Finding representative data is crucial (#13).
  • Evaluation: Assessing prompt programs requires qualitative evaluation (#14), and testing occurs at various scopes (#15).

Limitations and Future Work

Limitations:

  • Generalizability: The study acknowledges that the results may not generalize beyond their sample due to snowball sampling and self-selection bias.
  • Non-native Speakers: Interviews were conducted in English, potentially limiting representation from non-native speakers.
  • Company Policy: Some participants couldn't disclose all details due to company policies.
  • Evolving FM Performance: FM performance changes over time, meaning observations about model behavior might not remain consistent.
  • Subjectivity: As a qualitative study, interpretation of data introduces subjectivity.

Future Work:

  • Developer Tools: The authors emphasize the need for better developer tools that support the entire prompt programming lifecycle, including prototyping, dataset curation, regression testing, and collaboration.
  • Prompt Reuse: Research is needed on how to effectively reuse prompts, potentially through higher-level abstractions or community-based solutions, and how to retrieve relevant prompts.
  • Visualization: Developing new visualizations for FM output changes and prompt changes between versions is crucial.
  • Teaching Prompt Programming: Investigating effective methods to teach prompt programming, given the challenges of unreliable mental models and the lack of standardized best practices.
  • Understanding FM Evolution: Further research into how evolving FM capabilities impact prompt fragility and the overall prompt programming process.

Summary updated

BibTeX
@article{liang2025prompts,
  author = {Jenny T. Liang and Melissa Lin and Nikitha Rao and Brad A. Myers},
  title = {{Prompts Are Programs Too! Understanding How Developers Build Software Containing Prompts}},
  journal = {Proc. ACM Softw. eng},
  year = {2025},
  doi = {10.1145/3729342},
}
Figure