Literate programming means that instead of commenting your code (or feeling guilty for not doing so) you code your comments. Or rather you write a book about the problem your program solves, and in the narrative of the book you introduce aspects of code that solve the problem. As you do this you slowly reveal the solution - a well documented solution!
Literate programming helps one to write good code, because if one can't write a good justification or explanation for one's code, it makes one think again and write something that one can explain.
See this hello-world example in PDF rendering. The narrative explains hello-world as well as TeXmacs literate programming.
Fangle comes in two parts.
The weave part produces the formatted document is implemented entirely in TeXmacs macros (for TeXmacs) and Latex macros for Lyx.
The tangle part generates the source code is implemented in awk for portability across most unix-like or windows systems.
Naturally, fangle is written using literate programming techniques, using itself, and so the source is also the documentation.
The source was written using the Lyx document editor (an excellent front end to Latex) and then converted for TeXmacs which has a better WYSIWYG macro rendering system. TeXmacs and Lyx are not required, but fangle provides formatting support for TeXmacs and Lyx.
- Generics / macros. Fangle macros accept parameters, so generic algorithms can be expressed, and then invoked in the code using any particular types or parameters - like C macros, but with all the literate goodness and without all the backslash ugliness.
- Latex lstlistings used for code chunk formatting, with automatic markup for dozens of language types.
- Automatic escaping and quoting. You can include a shell-script chunk in a makefile and have all the $ escaped to $$ automatically in the extracted source. You can include a text file in a // comment or a " string and have the appropriate escaping done automatically!
- Never worry about code documentation again!
- Fangle has a makefile stub, Makefile.inc that will automatically extract all project sources, making fangle easy to integrate with standard Makefileprojects (including automake and autoconf).