Skip to content

Instantly share code, notes, and snippets.

@jmewes

jmewes/notes.md Secret

Created June 2, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmewes/8d9fd829285797c4ad3bb284f4cad2e2 to your computer and use it in GitHub Desktop.
Save jmewes/8d9fd829285797c4ad3bb284f4cad2e2 to your computer and use it in GitHub Desktop.
Literate Programming

https://www.youtube.com/watch?v=zYHsQarGaQ8

Donald Knuth, 2016, R Conference

Motivation

  • consider computer programs as literature

  • idea is to find the best way to explain a program to a human being

  • writing a program optimized for human readability first, compiler readability second.

Basic ideas

  • publication of computer programs as a book
  • think of a program as a hypertext
  • complexity from composition of lots of small simple parts
  • Small simple modules, connected to small other modules

Advantages

  • Diagrams, tables etc. can be kept beside the code
  • code may get rewritten when it is correct but difficult to explain
  • code can be understood by human beings
  • pedagogical style
  • also include design descisions
  • time saving comes from debugging through better understanding
  • May make some sort of very complex programs possible at all by reduction of congnitive load.

Disadvantages

  • a lot more work
  • more difficult to create

Examples

A Retargetable C Compiler: Design and Implementation, Christopher Fraser

  • This book is the implementation of LCC

Understanding MP3, Martin Ruckert

  • This book includes a complete MP3 player
  • You can zoom in on all the details if you want

Physically Based Rendering, Matt Pharr, Greg Humpherys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment