Literate Programming is a style of programming in which the programmer writes an essay instead of a program. The essay's code fragments are then merged together to form a full program which can be compiled or interpretted. This article is a literate program designed to perform this task with XML documents.
Donald Knuth's Literate Programming is a wonderful system for writing programs which are understandable and maintainable. It allows the programmer to not just communicate to the computer, but also communicate the ideas behind the program to current and future programmers. This idea has not caught on, but I believe it is still a worthy goal.
The current literate programming tools are problematic, however. They are still too wedded to individual programming languages and document formats. This program is a version of the tangle program which has the following features:
Works with any programming language
Uses XML as the documentation language
Is not tied to any specific DTD - instead it relies on processing instructions to perform it's tasks
Originally this program was written in C, only worked with the DocBook DTD, and only had a very primitive subset of the literate programming paradigm. Specifically, the code could only be broken up into files - it was not possible to include named code fragments which would be defined elsewhere - you could only append to files. This version is written in Python and captures much more of the literate paradigm.
|Python and Tangle|
Although this program is technically language-agnostic, it does have some practical problems with languages such as Python. Specifically, since Python's indentation is part of the language itself, it makes it difficult to write literate programs in Python. For example, if you have to insert code into a block, you have to know for sure how indented it is. In a future version, I will add language-specific extensions, including general <?lp-begin-block?> and <lp-end-block> processing instructions, and let the tangle program automatically indent the proper amount. In other languages, this can add the appropriate braces as well, although there would be less need for such a facility in those languages.
Need to include info on how it will actually work
|Outline of the program|