Next / Previous / Contents

3. A lightweight approach

We have tried to reduce to an absolute minimum the effort required to do literate programming and the complexity of the tools that we use to support it. Our goal was to enable anyone who can write both exposition and programs to combine the two in a literate-programming document with little or no extra effort or distraction.

We have developed an approach that we call "lightweight literate programming". The programmer simply inserts fragments of code between paragraphs of text, like this:

        def sayHello():
          print "Hello, world!"

The fragments appear in the same order as in the program that will be extracted from the document; there is no cross-referencing or reordering.

This style of presentation in the document is simple and clear. Many readers will find it familiar, because it is common in programming manuals, mathematics textbooks, scientific papers, and the like. There are no new notation conventions to learn or decipher.