Upgrade to Pro — share decks privately, control downloads, hide ads and more …

<textarea distributed>: An illustrated intro to CRDTs

Jason Orendorff
January 11, 2021

<textarea distributed>: An illustrated intro to CRDTs

Nodevember 2016.

[Full text of this talk](https://github.com/jorendorff/talks/blob/master/textarea-distributed/textarea-distributed.md) (much better than slides).

[Video of this talk](https://www.youtube.com/watch?v=vCkSLX7nR9Y) (still better than slides).

Jason Orendorff

January 11, 2021


  1. None
  2. None
  3. None
  4. shape of time can get strange

  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. …and that’s what I want to show you today. …go

    to this URL…
  15. I do want to take a moment before we begin

    to ask you to participate in the spirit of the thing.
  16. bit.ly/nv-clobber

  17. None
  18. This is the full state of our shared text editor.

    just a global string variable a text file is just a string
  19. I'm using a library called socket.io to handle networking between

    the browser and the server, because this talk isn't about networking. - simplest thing I could think of
  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. bit.ly/nv-quill

  31. None
  32. None
  33. None
  34. None
  35. bit.ly/nv-univax OK, obviously this works great, but it's not perfect.

    Let's say we want to collaborate and I'm in London… speed of light
  36. None
  37. None
  38. None
  39. None
  40. None
  41. …This approach is solid, but it hardcodes network latency right

    into the app. And it's at this point that I get a little frustrated. Why is this so hard?
  42. All we want to do is edit a text file.

  43. This should be easy.

  44. Instead we keep failing. Just one approach after another stinks,

  45. and the kids are starting to ask their mother, "Why

    is daddy so angry all the time?"
  46. None
  47. We could keep trying things, … So here's my question

    for you.
  48. None
  49. (discuss before next slide)

  50. if you work on web sites long enough… I picked

    text editing because it's little,…
  51. … the speed of light? It is just a fact

    of life … How do we rephrase this requirement as something possible?
  52. None
  53. And at the end we'll see if I ever actually

    got my collaborative text editor working, but for now we're going to set that aside …
  54. It's a kind of value that a computer knows how

    to deal with…
  55. String Number Array

  56. String Number Array text number sequence of values

  57. String Number Array text number sequence of values +, slice,

    replace, etc. +, -, *, Math.sqrt(), etc. arr[i], push, sort, etc.
  58. None
  59. 100% desirable… And that's all a CRDT is… example in

    a second. data type + ops over network + rules for conflicts …would solve our problem?
  60. String Now, a plain old string is not a CRDT.

    (why) But! … takes space … general pattern … add bookkeeping … not just text … history because conflicts.
  61. String +=

  62. This paper is only five years old.

  63. You can see … same things I’ve been talking about

    … … rethinking the fundamentals of programming and even of how we think about time … 14th example in this paper …
  64. None
  65. Their implementation is 38 lines of pseudocode. It took me

    about 200 lines of JS.
  66. None
  67. None
  68. None
  69. You would want to optimize.

  70. None
  71. bit.ly/nv-peeredit

  72. None
  73. None
  74. None
  75. None
  76. None
  77. github.com/jorendorff/peeredit