incremental interactive computation
play

Incremental Interactive Computation Matthew Hammer - PowerPoint PPT Presentation

Incremental Interactive Computation Matthew Hammer hammer@cs.umd.edu Tuesday, October 7, 2014 1 Incremental Interactive Computation Matthew Hammer hammer@cs.umd.edu Tuesday, October 7, 2014 2 Batch Computation vs Interactive Computation


  1. Incremental Interactive Computation Matthew Hammer hammer@cs.umd.edu Tuesday, October 7, 2014 1

  2. Incremental Interactive Computation Matthew Hammer hammer@cs.umd.edu Tuesday, October 7, 2014 2

  3. Batch Computation vs Interactive Computation Input Batch Model C Output No time, no dialogue Input Interactive Output C U Model Input Output Dialogue in time Tuesday, October 7, 2014 3

  4. Interaction is a Dialogue Creates input Time Time Demands Output U C Mutates input Demands Output Interacting Reactive User Computation Tuesday, October 7, 2014 4

  5. Elements of Interactive Dialogue • User and system interact across time • User mutates / changes input structure • User demands / observes output structure • The system maintains a correspondence between input and output structures • I/O correspondence is computational Tuesday, October 7, 2014 5

  6. Incremental Interactive Computation Tuesday, October 7, 2014 6

  7. Incremental Interactive Computation Claim: Interesting Input interactive Output C systems consist of U Input incremental computations Output Tuesday, October 7, 2014 7

  8. Example: Spreadsheets Input Cell Formulae Structure Incremental Formula Computation evaluation Output Cell values Structure Tuesday, October 7, 2014 8

  9. Example: Word processing Input Document Structure Content Incremental Spell-check Computation each word Output Highlight Structure misspellings Tuesday, October 7, 2014 9

  10. Example: Programming Input Text file Structure Computation Parse tokens Output AST Structure Input AST Structure Computation Lexical scoping Output Def/use edges Structure Input AST + Def/use Structure Computation Type inference Output Type errors Structure Tuesday, October 7, 2014 10

  11. Computing Incrementally 1. Input changes are gradual Full re-computation is often redundant 2. Output observation is limited Full re-computation is often overly eager Tuesday, October 7, 2014 11

  12. Computing Incrementally 1. Input changes are gradual 2. Output observation is limited Example: Cells change slowly Spreadsheet Document and Example: dictionary both Word processing change slowly Example: Program changes Programming slowly Tuesday, October 7, 2014 12

  13. Computing Incrementally 1. Input changes are gradual 2. Output observation is limited Example: One worksheet is Spreadsheet active, others hidden Example: Viewport shows one Word processing or two pages Viewport shows one Example: file, module or Programming function Tuesday, October 7, 2014 13

  14. Adapton Programming Abstractions for Incremental Interaction Tuesday, October 7, 2014 14

  15. Adapton Programming Abstractions • Mutable references: • Hold changing input structure • Lazy thunks: • Demand-driven computations • Output structure Tuesday, October 7, 2014 15

  16. Mutable 1 2 3 4 references + min max Incremental Computation (thunks) + * min max Demand-driven Outputs Tuesday, October 7, 2014 16

  17. Mutable 1 2 3 4 references + min max Incremental Computation (thunks) + * min max Demand-driven Outputs Tuesday, October 7, 2014 17

  18. Mutable 1 2 3 4 references max + min 2 5 Incremental Computation (thunks) + * 7 max min 7 Demand-driven Outputs Tuesday, October 7, 2014 18

  19. Mutable 1 2 3 4 references max + min 2 5 Incremental Computation (thunks) + * 7 max min 7 Demand-driven Outputs Switch Demand: Tuesday, October 7, 2014 19

  20. Mutable 1 2 3 4 references max + min 2 5 3 Incremental Computation (thunks) + * 7 15 max min 7 3 Demand-driven Outputs Switch Demand: Tuesday, October 7, 2014 20

  21. Mutable 1 2 3 4 references max + min 2 5 3 Incremental Computation (thunks) + * 7 15 max min 7 3 Demand-driven Outputs Sharing Tuesday, October 7, 2014 21

  22. Input Change: Mutable 1 2 3 4 references max + min 2 5 3 Incremental Computation (thunks) + * 7 15 max min 7 3 Demand-driven Outputs Tuesday, October 7, 2014 22

  23. Input Change: Mutable 1 10 3 4 references max + min 2 5 3 Incremental Computation (thunks) + * 7 15 max min 7 3 Demand-driven Outputs Some previous results are affected Tuesday, October 7, 2014 23

  24. Mutable 1 10 3 4 references max + min 2 5 3 Incremental Computation (thunks) + * 7 15 max min 7 3 Demand-driven Outputs Demand new output: Tuesday, October 7, 2014 24

  25. Mutable 1 10 3 4 references max + min 2 13 3 Incremental Computation (thunks) + * 7 26 max min 7 3 Demand-driven Outputs Demand new output: Tuesday, October 7, 2014 25

  26. Lazy Structures • Spreadsheet example: • Each thunk returns a single number • Lazy Lists: • Each thunk returns `Nil or `Cons • `Cons holds head value and a thunk tail • Laziness can be applied to trees , graphs , and essentially any other data structure • Inputs : Special thunks are mutable Tuesday, October 7, 2014 26

  27. Background: Lazy Lists type 'a thunk = unit -> 'a let force : 'a thunk -> 'a = fun t -> t () Apply unit argument type 'a lzlist = [ | `Nil | `Cons of 'a * ('a lzlist thunk) ] let rec from_list l = match l with | [] -> `Nil | h::t -> `Cons(h,fun()->from_list t) Tuesday, October 7, 2014 27

  28. type 'a lzlist = [ | `Nil | `Cons of 'a * ('a lzlist thunk) ] let rec merge l1 l2 = function |l1, `Nil -> l1 |`Nil, l2 -> l2 |`Cons(h1,t1), `Cons(h2,t2) -> if h1 <= h2 then `Cons(h1, fun()->merge (force t1) l2) else `Cons(h2, fun()->merge l1 (force t2)) Tuesday, October 7, 2014 28

  29. Mergesort Example Input [3,5,8,2,1,7] Singletons [ [3], [5], [8], [2], [1], [7] ] Merge #1 [ [3,5], [2,8], [1,7] ] Merge #2 [ [3,5], [1,2,7,8] ] Merge #3 [ [3,5], [1,2,7,8] ] Merge #4 [ [1, 2, 3, 5, 7, 8 ] ] Flatten [1, 2, 3, 5, 7, 8 ] Tuesday, October 7, 2014 29

  30. Course Project Tuesday, October 7, 2014 30

  31. Project: Interactive Program Analysis • Assume: Interactive “Structure Editor” • Programmer manipulates AST directly • Learn: Adapton IC framework • Build: Incremental Program Analysis • Example: Use/def information • Example: Type Inference • Example: Control-flow analysis Tuesday, October 7, 2014 31

  32. Background: Structure Editors • Philosophical claims: • Programs consist of rich structure • Rich interaction exposes this structure • Example prototypes: • Haskell -- http://www.youtube.com/watch?v=v2ypDcUM06U • Citris -- http://www.youtube.com/watch?v=47UcOspbZ2k • TouchDevelop -- http://www.youtube.com/watch?v=a6GRg2glKpc Tuesday, October 7, 2014 32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend