NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

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

Yu Wu, Wuyang Zhang, Yansong Li, Zeyu Dong, Yu Wu 0020, Yingyao Zhou, Duolei Wang, Songsirou Xing, Chichun Zhou, Da ShenarXiv 2025 · DOI

Introduction

While Large Language Models (LLMs) have revolutionized software development, their utility often hits a ceiling when transitioning from isolated functions to complex, large-scale projects. This paper proposes a revival and modernization of Donald Knuth’s 1984 concept of "Literate Programming" (LP) to bridge this gap. By introducing Interoperable Literate Programming (ILP), the authors provide a framework that forces LLMs to follow structured, inductive logic, significantly reducing hallucinations and improving architectural consistency.

The Challenge of Scale

LLMs face two primary hurdles in repository-level development:

  1. External Bias: Models often default to popular public libraries (e.g., PyTorch) even when a project utilizes specific internal APIs, leading to "hallucinated" dependencies.
  2. Inconsistent Solutions: Minor prompt variations can result in wildly different architectural choices, making it difficult to maintain a coherent logic across interdependent files.

Traditional code generation treats tasks as independent events. ILP addresses this by managing complex interdependencies, ensuring the LLM understands the "logical flow" of a project before generating code.

The Mogan Editor interface showing the interleaving of natural language documentation and code chunks for multiple files.

Interoperable Literate Programming (ILP)

ILP modernizes classical LP for the AI era through several key components:

  • The Step-wise Methodology: Inspired by mathematical induction, this framework breaks down API logic into a Zero-step (the base case) and a Successor-step (the inductive step explaining transitions). This aligns prompt engineering with recursive logical structures.
  • Goldfish Scheme as a Reasoning Catalyst: The authors utilize a specialized Scheme interpreter as a descriptive language. Because LLMs are not over-trained on Scheme compared to Python, they cannot rely on memorized snippets. This forces the model to engage in pure logical deduction based on the provided documentation.
  • Mogan Editor: A UTF-8 compatible editor that allows developers to "tangle" (export code) and "weave" (export documentation) within a single environment. This maintains a "web" of interconnected ideas rather than a linear file structure.
  • Directed Acyclic Graph (DAG) Structure: ILP represents the logical flow between APIs as a DAG, allowing LLMs to recursively search for and understand dependencies across different "chapters" of a project.
Demonstration of interoperability: a literate document exported into standard Jupyter notebooks and organized file structures.

Key Insights and Results

To prove LLMs were following documentation rather than training data, the authors employed the "Pinyin" Naming Trick, replacing standard function names (like map) with arbitrary terms (like the Mandarin Pinyin ditu). The LLMs successfully utilized these arbitrary names, confirming they were "reading the manual" rather than relying on external bias.

Performance Metrics

  • Consistency: ILP reduced variability in code quality across both high-end models (GPT-4o) and smaller, local models (Llama 3.1 2B, Qwen-14B).
  • Success Rates: In tests involving complex list manipulations, GPT-4o guided by ILP documentation consistently outperformed versions without file context.
  • Efficiency: The structured approach provided a clear, incremental path for the LLM, preventing it from being overwhelmed by global program logic.

Conclusion and Future Work

While ILP requires significant initial manual effort to document logic, it offers a robust path toward reliable AI-assisted engineering. Future research will focus on automating the generation of "step-wise" documentation from existing codebases and exploring transfer learning, where logic defined in Scheme is used to generate code in target languages like Python or Java.

Summary updated

BibTeX
@misc{wu2025renaissance,
  author = {Yu Wu and Wuyang Zhang and Yansong Li and Zeyu Dong and Yu Wu and Yingyao Zhou and Duolei Wang and Songsirou Xing and Chichun Zhou and Da Shen},
  title = {{Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projects}},
  year = {2025},
  eprint = {2502.17441},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.17441},
}
Figure