Skip to main content
QUICK REVIEW

[Paper Review] Data-Driven Program Completion

Yanxin Lu, Swarat Chaudhuri|arXiv (Cornell University)|May 25, 2017
Software Engineering ResearchComputer Science20 references11 citations
TL;DR

This paper introduces program splicing, a data-driven synthesis approach that automates code completion by combining programmer-provided drafts—featuring incomplete code, comments, and test cases—with a database of 3.5 million real-world Java snippets. The method uses relevance-based snippet retrieval and combinatorial enumeration of codelets to complete programs efficiently, demonstrating significant productivity gains in both automated benchmarks and user studies.

ABSTRACT

We introduce program splicing, a programming methodology that aims to automate the commonly used workflow of copying, pasting, and modifying code available online. Here, the programmer starts by writing a "draft" that mixes unfinished code, natural language comments, and correctness requirements in the form of test cases or API call sequence constraints. A program synthesizer that interacts with a large, searchable database of program snippets is used to automatically complete the draft into a program that meets the requirements. The synthesis process happens in two stages. First, the synthesizer identifies a small number of programs in the database that are relevant to the synthesis task. Next it uses an enumerative search to systematically fill the draft with expressions and statements from these relevant programs. The resulting program is returned to the programmer, who can modify it and possibly invoke additional rounds of synthesis. We present an implementation of program splicing for the Java programming language. The implementation uses a corpus of over 3.5 million procedures from an open-source software repository. Our evaluation uses the system in a suite of everyday programming tasks, and includes a comparison with a state-of-the-art competing approach as well as a user study. The results point to the broad scope and scalability of program splicing and indicate that the approach can significantly boost programmer productivity.

Motivation & Objective

  • To address the widespread but error-prone practice of copying and pasting code from online sources by providing a principled, automated alternative.
  • To reduce the burden of manual code modification and debugging during integration of external code by enabling context-aware program synthesis.
  • To improve scalability and correctness in program synthesis by leveraging real-world code from open-source repositories as a knowledge base.
  • To support programmers in completing partial programs using natural language comments and test cases as specifications, minimizing manual effort.
  • To evaluate the effectiveness of data-driven synthesis in real-world programming tasks and compare it with state-of-the-art approaches.

Proposed method

  • The system accepts a programmer's draft containing incomplete code, natural language comments, and correctness constraints (e.g., test cases or API call sequences).
  • A database of 3.5 million Java methods from open-source repositories is used to retrieve semantically relevant code snippets based on the draft's content.
  • Relevant snippets are analyzed to extract codelets—reusable expressions and statements—considered likely to fill the holes in the draft.
  • An enumerative search algorithm systematically combines these codelets with the draft, guided by heuristics to prune the search space.
  • The synthesis process is iterative: the resulting program can be further modified and resubmitted for additional rounds of completion.
  • The approach avoids statistical models and instead relies on combinatorial search over real, human-written code, reducing the risk of nonsensical or syntactically invalid outputs.

Experimental results

Research questions

  • RQ1Can a data-driven synthesis approach effectively automate the completion of partially written programs using real code snippets from open-source repositories?
  • RQ2How does program splicing compare in performance and usability to existing synthesis tools like μScalpel in common programming tasks?
  • RQ3To what extent can program splicing reduce programmer effort and increase productivity in real-world coding scenarios?
  • RQ4How effective is the use of codelets from real programs in guiding the synthesis process toward correct and readable solutions?
  • RQ5Can the system handle diverse programming tasks, including algorithm modifications, GUI development, and component prototyping, with minimal specification?

Key findings

  • The system successfully completed a suite of everyday programming tasks, including algorithm modifications, GUI development, and HTTP server prototyping, using only comments and test cases as input.
  • In comparison to μScalpel, a state-of-the-art synthesis tool, program splicing demonstrated broader applicability and higher success rates across diverse tasks.
  • A user study showed that developers using program splicing completed tasks significantly faster and with fewer errors than with traditional copy-paste workflows.
  • The approach achieved high scalability, processing synthesis tasks over a corpus of 3.5 million Java methods with low latency.
  • The use of real codelets from production code improved the readability and correctness of synthesized programs, reducing the likelihood of semantic or syntactic bugs.
  • Iterative synthesis rounds enabled refinement of results, allowing developers to iteratively improve and adapt generated code with minimal rework.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.