literate programming
play

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


  1. Literate Programming in the Twenty-first Century Howard Abrams www.howardism.org @ howardabrams

  2. Thesis

  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

  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

  5. Computer programming is an art… especially because it produces objects of beauty. A programmer who subconsciously views himself as an artist will enjoy what he does and will do it better. —Donald Knuth

  6. 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

  7. 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

  8. Tangling 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

  9. Tangling Weaving 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

  10. 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; @

  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; @ Start of code block marker

  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; @ End of code block Start of code block marker

  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; @ End of code block Code Start of code block marker

  14. We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. <<Global variables>>= Global variables long total_word_count, total_line_count, total_char_count; @ Name of Code block End of code block Code Start of code block marker

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

  16. 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 ... We must include the standard I/O definitions, since we want to send formatted output to stdout and stderr. Here, then, is an overview of the file <<Global variables>>= long total_word_count, wc.c that is defined by the noweb total_line_count, total_char_count; program wc.nw: @ <<*>>= <<Header files to include>> <<Definitions>> <<Global variables>> <<Functions>> <<The main program>> @

  17. 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 We must include the standard I/O program wc.nw: definitions, since we want to send formatted output to stdout and stderr. <<*>>= <<Global variables>>= <<Header files to include>> long total_word_count, total_line_count, <<Definitions>> total_char_count; <<Global variables>> @ <<Functions>> <<The main program>> @

  18. 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 We must include the standard I/O program wc.nw: definitions, since we want to send formatted output to stdout and stderr. <<*>>= <<Global variables>>= long total_word_count, <<Header files to include>> total_line_count, <<Definitions>> total_char_count; <<Global variables>> @ <<Functions>> <<The main program>> @

  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 We must include the standard I/O program wc.nw: definitions, since we want to send formatted output to stdout and stderr. <<*>>= <<Global variables>>= long total_word_count, <<Header files to include>> total_line_count, <<Definitions>> total_char_count; <<Global variables>> @ <<Functions>> <<The main program>> @ <<Functions>>= <<Count words in array>> <<Separate words>> <<Is punctuation?>> @

  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 We must include the standard I/O program wc.nw: definitions, since we want to send formatted output to stdout and stderr. <<*>>= <<Global variables>>= long total_word_count, <<Header files to include>> total_line_count, <<Definitions>> total_char_count; <<Global variables>> @ <<Functions>> <<The main program>> <<Count words in array>>= @ // ... @ <<Functions>>= <<Count words in array>> <<Separate words>>= <<Separate words>> // ... <<Is punctuation?>> @ @ <<Is punctuation?>>= // ... @

  21. Antithesis

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

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

  24. A wise engineering solution would produce—or better, exploit—reusable parts. —Doug McIlory tr -cs A-Za-z '\n' | tr A-Z a-z | s ' t i , y y n l d n sort | l u i f w s t ' t i I d . t n n a i uniq -c | o , e p l b s ' z a h s t t u e u P e n r K o sort -rn | P s — e s s i m sed ${1}q

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

  26. Influences • Javadoc System • Docco • iPython Notebook • Haskell • Embraced by Cryptic Languages

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

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

  29. A page is a series of “cells”

  30. Executed code is displayed below

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

  32. Synthesis

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

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

  35. Tangling Weaving 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010

  36. Tangling Weaving 010111010001 100111100110 101010010010 101010100101 101010111001 101011010100 011110011010 REPL Connect to Interpreters

  37. Prose Code Prose Code Prose Code Prose

  38. Lists, tables and textual data fed in as variables

  39. Lists, tables and textual data fed in as variables

  40. Results of running code inserted as data

  41. Results of that code given as variables to other code blocks

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

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

  44. The Toolbox Babel org-mode Emacs Language Modes Graphviz/PlantUML REPL Connectors

  45. Demonstration

  46. Possible Uses • Learning a new language • Combining code with its or technology tests • Better REPL for non- • Easier to brain-storm interactive languages over complex analysis • Problems require • Describe complex code: multiple languages • Regular Expressions • Embedded UML or • Odd inheritance trees other diagrams • SQL and ORM

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

Recommend


More recommend