Literate Programming in the Twenty-first Century Howard Abrams - - PowerPoint PPT Presentation

literate programming
SMART_READER_LITE
LIVE PREVIEW

Literate Programming in the Twenty-first Century Howard Abrams - - PowerPoint PPT Presentation

Literate Programming in the Twenty-first Century Howard Abrams www.howardism.org @ howardabrams Thesis Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer


slide-1
SLIDE 1

Literate Programming

in the

Twenty-first Century

Howard Abrams www.howardism.org

@howardabrams

slide-2
SLIDE 2

Thesis

slide-3
SLIDE 3

Let us change our traditional attitude to the construction of programs. 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

slide-4
SLIDE 4

The programmer's task is to state [the] parts and relationships, in whatever order is best for human comprehension not in some rigidly determined order like top-down or bottom-up.

—Donald Knuth

slide-5
SLIDE 5

—Donald Knuth

Computer programming is an art… especially because it produces

  • bjects of beauty. A programmer

who subconsciously views himself as an artist will enjoy what he does and will do it better.

slide-6
SLIDE 6
slide-7
SLIDE 7

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

slide-8
SLIDE 8

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

slide-9
SLIDE 9

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

Tangling

slide-10
SLIDE 10

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

Tangling Weaving

slide-11
SLIDE 11

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

slide-12
SLIDE 12

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

Start of code block marker

slide-13
SLIDE 13

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

Start of code block marker End of code block

slide-14
SLIDE 14

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

Start of code block marker End of code block Code

slide-15
SLIDE 15

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

Start of code block marker End of code block Code Name of Code block

Global variables

slide-16
SLIDE 16

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

slide-17
SLIDE 17

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

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 ...

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>> @

slide-18
SLIDE 18

We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

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 ...

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>> @

slide-19
SLIDE 19

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 ...

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. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

slide-20
SLIDE 20

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 ...

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. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

<<Functions>>= <<Count words in array>> <<Separate words>> <<Is punctuation?>> @

slide-21
SLIDE 21

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 ...

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. <<Global variables>>= long total_word_count, total_line_count, total_char_count; @

<<Functions>>= <<Count words in array>> <<Separate words>> <<Is punctuation?>> @

<<Count words in array>>= // ... @ <<Is punctuation?>>= // ... @ <<Separate words>>= // ... @

slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25

Antithesis

slide-26
SLIDE 26

A wise engineering solution would produce—or better, exploit—reusable parts. —Doug McIlory

slide-27
SLIDE 27

A wise engineering solution would produce—or better, exploit—reusable parts. —Doug McIlory tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q

slide-28
SLIDE 28

A wise engineering solution would produce—or better, exploit—reusable parts. —Doug McIlory tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q

I t ' s f u n n y , i t ' s r e u s a b l e , a n d i t w i l d l y m i s s e s K n u t h ' s p

  • i

n t . — P

  • P

e t z

slide-29
SLIDE 29

Donald Knuth Doug McIlroy Code re-use Better thinking through better tools

slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33

Influences

  • Javadoc System
  • Docco
  • iPython Notebook
  • Haskell
  • Embraced by Cryptic Languages
slide-34
SLIDE 34

http://aanandprasad.com/articles/negronis/

slide-35
SLIDE 35

http://aanandprasad.com/articles/negronis/

slide-36
SLIDE 36
slide-37
SLIDE 37

A page is a series

  • f “cells”
slide-38
SLIDE 38

Executed code is displayed below

slide-39
SLIDE 39

Cells can contain text in Markdown format, which is automatically rendered.

slide-40
SLIDE 40

Synthesis

slide-41
SLIDE 41

What is Needed?

  • Good text processing and programming
  • Identify and separate source code snippets
  • Code block evaluation support
  • Link and reference code block snippets
  • Use evaluated code output
  • Render both code and documentation
slide-42
SLIDE 42

In the third millenium, does it still make sense to work with text files? Text files are the only truly portable format for

  • files. The data will never get lost.

—Carsten Dominik

slide-43
SLIDE 43

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

Tangling Weaving

slide-44
SLIDE 44

010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

Tangling Weaving Connect to Interpreters REPL

slide-45
SLIDE 45
slide-46
SLIDE 46

Prose Prose Prose Prose Code Code Code

slide-47
SLIDE 47

Lists, tables and textual data fed in as variables

slide-48
SLIDE 48

Lists, tables and textual data fed in as variables

slide-49
SLIDE 49

Results of running code inserted as data

slide-50
SLIDE 50

Results of that code given as variables to other code blocks

slide-51
SLIDE 51

A complex piece of software is best regarded as a web of ideas that has been delicately pieced together from simple materials. —Knuth

slide-52
SLIDE 52

Knuth originally interconnected code. Now we can interconnect both code and data in a literate way.

slide-53
SLIDE 53

Emacs

The Toolbox

Language Modes Graphviz/PlantUML REPL Connectors

  • rg-mode

Babel

slide-54
SLIDE 54

Demonstration

slide-55
SLIDE 55

Possible Uses

  • Learning a new language
  • r technology
  • Better REPL for non-

interactive languages

  • Problems require

multiple languages

  • Embedded UML or
  • ther diagrams
  • Combining code with its

tests

  • Easier to brain-storm
  • ver complex analysis
  • Describe complex code:
  • Regular Expressions
  • Odd inheritance trees
  • SQL and ORM
slide-56
SLIDE 56

Questions?

http://is.gd/XPGMR6 Links to this presentation and other bookmarks available at either this URL or scan this QR code: