In literate programming, the source code of a program and its technical documentation are integrated into a single artifact, and the programmer writes both at the same time.
The essence of literate programming is to write a computer program as you would write an essay. The inventor of the concept was Donald E. Knuth, an eminent computer scientist. Knuth wrote:
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. [Knuth 1984]
A literate program, then, is both a program and an essay explaining a program. It describes what the various parts of a program are intended to do, why they were designed the way they were, and anything else about the program code that the programmer thinks is important. This information is a critical part of the documentation of a program; it is called "internal" or "technical" documentation, as distinguished from the "external" or "user" documentation that includes help systems and user manuals.
In literate programming the essay is the central artifact, and it includes the program code as figures or displays. Typically, the code is presented in many short fragments, each one appearing within or below the paragraphs that explain it. The literate program is written as an electronic document, and the fragments of code are included in such a way that they can be extracted by other software to produce an executable program.
One could produce something looking like a literate program by writing the code and its documentation separately and cutting-and-pasting them together into a single file, but this would be missing the point. A literate program is written as a unified composition, as a single creative act. The result is a single source of content that can be processed to give both an executable program and human-readable documentation for that program.