Angelo Basile

Org-mode Babel is cool

Literate programming is what you need to rise above the ordinary level of achievement. But I don’t believe in forcing ideas on anybody. If literate programming isn’t your style, please forget it and do what you like. If nobody likes it but me, let it die.

In a learning environment it is often the case that comments are longer than code lines, therefore literate programming looks like the natural paradigm to adopt. And Babel is the perfect tool for literate programming.

If you are given a script and you have to modify it, comment and then send it back to your instructor, then Babel comes really in handy: you start by putting the whole script in one big code block, and as you start commenting and modifying it, you just split it and add the comments as pure text between blocks.

It might be the case that you only have to submit the script as a single, executable file: in that case all you have to do is calling the org-babel-tangle function and emacs will create a new file named after your *.org file but containing only source code.

I define the options for Babel per buffer by putting the following line on top of my *.org document.