…and that’s what I want to show you today.
…go to this URL…
Slide 15
Slide 15 text
I do want to take a moment before we begin
to ask you to participate in the spirit of the thing.
Slide 16
Slide 16 text
bit.ly/nv-clobber
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
This is the full state of our shared text editor.
just a global string variable
a text file is just a string
Slide 19
Slide 19 text
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
Slide 20
Slide 20 text
No content
Slide 21
Slide 21 text
No content
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
bit.ly/nv-quill
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
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
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
No content
Slide 38
Slide 38 text
No content
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
…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?
Slide 42
Slide 42 text
All we want to do is edit a text file.
Slide 43
Slide 43 text
This should be easy.
Slide 44
Slide 44 text
Instead we keep failing.
Just one approach after another stinks,
Slide 45
Slide 45 text
and the kids are starting to ask their mother,
"Why is daddy so angry all the time?"
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
We could keep trying things, …
So here's my question for you.
Slide 48
Slide 48 text
No content
Slide 49
Slide 49 text
(discuss before next slide)
Slide 50
Slide 50 text
if you work on web sites long enough…
I picked text editing because it's little,…
Slide 51
Slide 51 text
… the speed of light?
It is just a fact of life …
How do we rephrase this requirement as something possible?
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
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 …
Slide 54
Slide 54 text
It's a kind of value that a computer knows how to deal with…
Slide 55
Slide 55 text
String
Number
Array
Slide 56
Slide 56 text
String
Number
Array
text
number
sequence
of
values
Slide 57
Slide 57 text
String
Number
Array
text
number
sequence
of
values
+, slice, replace, etc.
+, -, *, Math.sqrt(), etc.
arr[i], push, sort, etc.
Slide 58
Slide 58 text
No content
Slide 59
Slide 59 text
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?
Slide 60
Slide 60 text
String
Now, a plain old string is not a CRDT. (why)
But! … takes space … general pattern … add bookkeeping …
not just text … history because conflicts.
Slide 61
Slide 61 text
String +=
Slide 62
Slide 62 text
This paper is only five years old.
Slide 63
Slide 63 text
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 …
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
Their implementation is 38 lines of pseudocode.
It took me about 200 lines of JS.