immutability
play

Immutability, or Putting the Dream Machine to Work The trie memory - PowerPoint PPT Presentation

Immutability, or Putting the Dream Machine to Work The trie memory scheme is ine ffi cient for small memories, but it be- comes increasingly e ffi cient in using available storage space as memory size increases. The attractive features of the


  1. Immutability, or Putting the Dream Machine to Work

  2. The trie memory scheme is ine ffi cient for small memories, but it be- comes increasingly e ffi cient in using available storage space as memory size increases. The attractive features of the scheme are these: 1) The retrieval process is extremely simple. Given the argument, enter the standard ini- tial register with the fi rst character, and pick up the address of the second. Then go to the second register, and pick up the address of the third, etc. 2) If two arguments have initial characters in common, they use the same storage space for those characters. -J.C.R. Licklider, "Man-Computer Symbiosis" 1960

  3. Model-View-Controller

  4. ๏ fi rst formulated by Trygve Reenskaug Adele Goldberg and others at Xerox PARC in 1979 ๏ long shadow, the basic concepts still prevalent today.

  5. ๏ At a very abstract level MVC is a sound separation of concerns ๏ Implementations leave much to be desired ๏ Stateful objects everywhere

  6. Functional Programming and Data • immutable values, not mutable objects • “change” returns a new value, leaving the old one unmodified • they’re persistent • they’re fast

  7. Simple example: Linked List X

  8. Simple example: Linked List Y X

  9. Simple example: Linked List Y X Z

  10. Simple example: Linked List structural sharing Y X Z

  11. Sharing structure • space e ffj ciency • computational e ffj ciency – avoids copying

  12. Phil Bagwell • Array Mapped Trie • Hash Array Mapped Trie

  13. Bitmapped Vector Trie • data lives in the leaves • e.g. prefix tree used for string lookup • bitwise trie

  14. Persistent Vector

  15. Persistent Vector

  16. Persistent Vector

  17. Persistent Vector

  18. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  19. Persistent Vector getindex

  20. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  21. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 0b01101010

  22. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 0b01101010

  23. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 0b01101010

  24. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 0b01101010

  25. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 0b01101010

  26. Persistent Vector assoc

  27. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  28. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  29. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  30. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

  31. Persistent Vector 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 104 105 foo 107

  32. Persistent Vector Length 4 internal vectors?

  33. Persistent Vector 32 From Bagwell, Rompf 2011

  34. 32 7

  35. 34,359,738,368 elements

  36. demo

  37. Om

  38. f(D 0 ) = V 0

  39. f(D 1 ) = V 1

  40. di ff (V 0 ,V 1 ) = CHANGES

  41. demo

  42. Persistent Data Structures … ROCK

  43. Questions?

Recommend


More recommend