Table of Contents
Fetching ...

Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projects

Wuyang Zhang, Yansong Li, Zeyu Dong, Yu Wu, Yingyao Zhou, Duolei Wang, Songsirou Xing, Chichun Zhou, Da Shen

TL;DR

This work tackles the difficulty of applying LLM-based code generation to large-scale software with intricate interdependencies. It introduces Interoperable Literate Programming (ILP), a framework that extends Knuth's literate programming with a uniform core schema and a DAG-based description of API interdependencies, implemented via Goldfish Scheme and the Mogan editor. An llm interaction layer provides explicit annotations (pattern, complexity, examples) to guide reasoning and reduce external bias, while a step-wise documentation design uses zero-step and successor-step induction to structure logic across files. The experiments on RepoBench demonstrate that ILP reduces variability in generated code, improves cross-file consistency, and enhances edge-case handling, with notable gains for smaller models; the approach also supports Python and Scheme code generation within large project contexts. Overall, ILP promises more reliable, scalable, and interpretable LLM-assisted development for complex codebases by tightly integrating documentation, code, and inter-file dependencies.

Abstract

Large Language Models (LLMs) have helped programmers increase efficiency through code generation, comprehension, and repair. However, their application to large-scale projects remains challenging due to complex interdependencies and the extensive size of modern codebases. Although Knuth's concept of Literate Programming (LP) combines code and natural language to convey logic and intent, its potential for enhancing relationships in large projects has not been fully explored. In this study, we introduce the idea of Interoperable LP (ILP), which leverages literate programming principles to enhance the development of both small-scale documents and large-scale projects with LLMs. We investigate how LLMs perform under ILP-style instructions for both document-oriented tasks and entire projects. Recognizing that many researchers rely on well-structured templates to guide LLMs, we propose a concise prompt engineering method to write LP documents so LLMs can better be involved in code generation. We also examine the capacity of various LLMs to generate Scheme and Python code on the RepoBench benchmark, illustrating the advantages of our approach. Our findings indicate that ILP with LLMs can enhance LLM-based code generation in large-scale project development.

Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projects

TL;DR

This work tackles the difficulty of applying LLM-based code generation to large-scale software with intricate interdependencies. It introduces Interoperable Literate Programming (ILP), a framework that extends Knuth's literate programming with a uniform core schema and a DAG-based description of API interdependencies, implemented via Goldfish Scheme and the Mogan editor. An llm interaction layer provides explicit annotations (pattern, complexity, examples) to guide reasoning and reduce external bias, while a step-wise documentation design uses zero-step and successor-step induction to structure logic across files. The experiments on RepoBench demonstrate that ILP reduces variability in generated code, improves cross-file consistency, and enhances edge-case handling, with notable gains for smaller models; the approach also supports Python and Scheme code generation within large project contexts. Overall, ILP promises more reliable, scalable, and interpretable LLM-assisted development for complex codebases by tightly integrating documentation, code, and inter-file dependencies.

Abstract

Large Language Models (LLMs) have helped programmers increase efficiency through code generation, comprehension, and repair. However, their application to large-scale projects remains challenging due to complex interdependencies and the extensive size of modern codebases. Although Knuth's concept of Literate Programming (LP) combines code and natural language to convey logic and intent, its potential for enhancing relationships in large projects has not been fully explored. In this study, we introduce the idea of Interoperable LP (ILP), which leverages literate programming principles to enhance the development of both small-scale documents and large-scale projects with LLMs. We investigate how LLMs perform under ILP-style instructions for both document-oriented tasks and entire projects. Recognizing that many researchers rely on well-structured templates to guide LLMs, we propose a concise prompt engineering method to write LP documents so LLMs can better be involved in code generation. We also examine the capacity of various LLMs to generate Scheme and Python code on the RepoBench benchmark, illustrating the advantages of our approach. Our findings indicate that ILP with LLMs can enhance LLM-based code generation in large-scale project development.

Paper Structure

This paper contains 61 sections, 9 figures, 1 table.

Figures (9)

  • Figure 1: Comparison: literate programming with Mogan and Jupyter Notebook programming
  • Figure 2: The whole project can be exported from the literate programming document with Build buffer button in Mogan.
  • Figure 3: Comparison of a literate programming approach (left), which organizes code as a “web” of interconnected ideas, versus a typical Jupyter Notebook workflow (right) that does not follow literate programming principles.
  • Figure 4: Goldfish Scheme as descriptive contents in ilp.
  • Figure 5: The DAG structure and the corresponding Scheme description of the extended add function are shown in Fig. \ref{['subfig:web_idea_mogan']}.
  • ...and 4 more figures