Literate programming in org-mode


Table of Contents

  • 1 Literate programming
  • 2 org-babel

1 Literate programming

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. — Donald Knuth (author of the art of computer programming)

This is a revolutionary opinion in software history, Knuth even has his own literate programming language named the web(not the same thing with internet web). He used cweb tools to write most of his source code which can be found on his webpage.

Literate programming is actually a software development method, which combines documenting and programming process into one job. In that way, the document and source code are tangled. The source code developed by programmers is also the document for that.

There are some examples of this programming style. Some technique books like C Interfaces and Implementations was write in this way, the source code of the examples in this book is also embedded in the books itself. Donald E. Knuth built the famous tex (a typesetting system) by his web literate language.

So how to build the target executable program from the source code mixed with the document? In Knuth's web literate language, there are two tools: ctangle to extract c source code, cweave to extract document. Then the C source code is compiled to target object.

Literate programming is pretty cool, huh. But I believe literate programming still in the academic research field, and it still unacceptable by engineers. Why? Because the engineers have their own ways to make source code readable and his own documentation method. In a good team, engineers work together with same programming style, they do not need any document to understand his colleague's source code, the best document of his source code is the source code itself. And the best way to fix the puzzles in the source code is face to face argument. Engineer's pleasure comes from the operating pattern evolved from his daily work, it comes from his emacs programming environment and come from his skilled fingers tapping the keyboards. I think that's the gap between scientist and engineers.

2 org-babel

org-babel developed by Eric Schulte. I guess its name come from the tower of babel which is a building intended to connect to heaven, but this project was disrupted by god, who let people have different languages to stop human beings work together.
org-babel is one way to let multi-language work together. what's more, it is also a literate programming tool. The org-babel's author also provide a great example to practice literate programming, project named emacs start kit. With the help of emacs, org-babel may be the right literate programming tools.

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp