Literate Programming: What is it?

Written by Rui Curado on November 4th, 2008

Literate Programming (LP) is a computer programming methodology based on the principle that a computer program should be written like a book, newspaper or report, with human readability as its primary goal. Donald Knuth coined the term Literate Programming and created the original LP tool/language, WEB, which he used to write TeX and MetaFont.

While I personally don’t agree with all Literate Programming’s principles, I do agree that extensively documenting an application leads to long term gains.

Is literate programming a good thing? I believe it is. I guess it depends on how you feel about programming. If you are up against a deadline for getting code finished and working, trying to make a literate program instead of a working program might seem foolish. However, in long-term projects (all that code you plan to maintain in the near future), Literate Programming actually does seem to pay off.

One of the best examples of Literate Programming support is a programmer’s outlining editor called Leo, available at http://leo.sourceforge.net. With Leo you can organize your code in an intuitive manner, and at the same time organize and embed the description and specification of that very same code. Leo supports noweb  and CWEB markup. You should definitively try it if you want to write more than just code.

I’ve been applying LP’s dogma for a long time in my development efforts. I do not use the WEB-derived tools but I make sure all code, classes and methods are all well documented at coding time. That’s why my average comment line percentage in my projects goes around 40%. And it sure does pay off!

My microISV, Isomeris, is developing a Code Generator IDE that allows painless integration of Literate Programming in software projects. Stay tuned to find out more.

2 Comments so far ↓

  1. Feb
    24
    10:20
    PM
    Rui Pacheco

    O link para o Leo nao funciona.

  2. Feb
    24
    10:43
    PM
    Rui Curado

    Obrigado, Rui. Já corrigi.

Spruce up your comments with
<a href="" title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong>
New comments are moderated before being shown * = required field

Leave a Comment