Literate Programming

Yash Soni
Yash Soni / April 24, 2020
2 min read

When we usually write any computer program, we generally have this mindset of instructing a computer what we want it to do. But computer programms/code is not meant to be in closed private files. We want others to learn from it or contribute to it. The ways to make others understand what we really intended the program to do is usually by comments or readme docs.

Literate Programming is a programming paradigm introduced by Donald Knuth. He introduced this idea to consider programs to be works of literature.

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.

The practitioner of literate programming can be regarded as an essayist, who treats a program as literature understandable to human beings, prioritizing the programmer’s own thought process.

Literate Computing

So we undersood the concepts of Literate Programming. But, how do we practice it now?

Enter Literate Computing environments.

A literate computing environment is a platform for literate programming. It allows users to create content, provide code, and execute/modify the program to experiment with output — all in one interface, saved to one file.

Getting your hands dirty

If you are comfortable in python, you can try your hands at Jupyter notebooks. Head over to this link to test it in your browser.

Google has its own version of python notebooks in form of Colaboratory.

For Javascript, checkout ObservableHq. The homepage itself will give you an idea of what it is about. This notebook by the founder himself explains beautifully what observable notebooks are.

I have my own share of experiments with Jupyter notebooks.