Literate programming

Programmation lettrée

"Nous devons changer notre attitude traditionnelle envers la construction des programmes :
au lieu de considérer que notre tâche principale
est de dire à un ordinateur ce qu'il doit faire,
appliquons-nous plutôt à expliquer à des êtres humains ce que nous voulons que l'ordinateur fasse."

 

- Donald E. Knuth, Literate Programming (1984)

"Ce que l'on conçoit bien s'énonce clairement,
Et les mots pour le dire arrivent aisément."

 

- Nicolas Boileau, L'Art Poétique (1674)

source

code
executable

documentation complète

"tangling"

"weaving"

The purpose of wc is to count lines, words, and/or characters in a list of files. The number of lines in a file is ......../more explanations/

Here, then, is an overview of the file wc.c that is defined by the noweb program wc.nw:
    <<*>>=
    <<Header files to include>>
    <<Definitions>>
    <<Global variables>>
    <<Functions>>
    <<The main program>>
    @

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr.
    <<Header files to include>>=
    #include <stdio.h>
    @
The present chunk, which does the counting, was actually one of the simplest to write. We look at each character and change state if it begins or ends a word.

    <<Scan file>>=
    while (1) {
      <<Fill buffer if it is empty; break at end of file>>
      c = *ptr++;
      if (c > ' ' && c < 0177) {
        /* visible ASCII codes */
        if (!in_word) {
          word_count++;
          in_word = 1;
        }
        continue;
      }
      if (c == '\n') line_count++;
      else if (c != ' ' && c != '\t') continue;
      in_word = 0;
        /* c is newline, space, or tab */
    }
    @

description explicite de la logique

=> moins de bugs de conception

meilleure documentation,
établie au fur et à mesure

plus facile d'interrompre et de reprendre
l'écriture du programme

TeX, metafont

outillage

WEB (1984, TeX + Pascal)

CWEB (1987-2006, TeX + C/C++/java)

noweb (1989-2011, TeX/LaTeX/HTML + tous langages)

adoption

literate Haskell...

Mathematica : computational essay

IPython/Jupyter Notebook

Mike Bostock

NY Times, D3.js

Jeremy Ashkenas

Underscore.js, CoffeeScript, backbone.js

Tom McWright

Mapbox

bl.ocks.org

javascript libraries for
data-driven documents

a simple viewer for sharing code examples hosted on GitHub Gist.

ex: https://bl.ocks.org/mbostock/4348373

the integrated discovery environment

d3.express

2011

2012

2013

2014

2015

2016

2017

2018

Observable

http://beta.observablehq.com
a web-first interactive notebook for data
analysis, visualization, and exploration

reactivity

visibility

reusability

portability

Made with Slides.com