GAVIN DOUGHTIE: I am Gavin Doughtie.
I am an engineer on the AdWords mobile team.
We're using Flutter.
And you're lying about your state,
but I hope only to yourselves.
So since we're at a cutting-edge tech conference,
I'm going to go all the way back to 1981
and the introduction of the Xerox Star
personal workstation.
Now, this computer is famed in computer history
for introducing things like the graphical user
interface and the mouse and a bunch of other stuff
that Steve Jobs might have seen once upon a time.
But it also included this, which is the Smalltalk programming
language.
Now, this was actually one of the major innovations
of this computer.
Smalltalk was a deeply object-oriented language.
And it heavily influenced all the languages that came after,
including Objective-C and Java.
And of course, Dart.
But one thing that it did that's different from those languages
is it exposed an integrated graphical user environment that
encouraged you to think about the system
not as a bunch of source code files,
but as a bunch of live objects that you
could inspect and change and add more classes to.
And not just the objects that might be in your application,
but objects in the runtime environment as well.
For example, the CEO at the startup
where I was using Smalltalk was not an engineer.
And when they saw the red debugger window pop up,
she was like, oh, these engineers
are not doing their jobs.
They shouldn't have bugs.
So we were able to change the background color to blue.
[LAUGHTER]
So another thing that Smalltalk did
was it promoted the idea of a model view controller
architecture.
And we're not going to go into this,
but I'm sure you guys have read a lot about it.
And this was very innovative at the time.
You could have things like your model encapsulating logic
as well as the data that operate--
as well as the data that that logic operated on.
And it gave you a nice separation of concerns.
But this was a while ago, and the Xerox Star,
and many of the other computers that came along afterwards,
were kind of designed around the assumption
that you had a single user sitting
at a single machine using a single object model that
was sitting in memory and was very sporadically updated.
It tended to be like slurp it off disk, show it in memory,
and splat it back down at the end when you saved your files.
And this model is really old and not really relevant anymore.
So the way that data works in your applications today
is more like this, where you've got multiple users.
You've got multiple sensors.
You've got data being updated in real time, right?
Or you have something like this, where you have-- you might even
have the same user using two devices,
like, oh, I'm going to do some stuff on my phone,
and now I'm going to jump over to my desktop
and make some edits.
And five other people doing the same thing at the same time.
And the idea that I want you to take away with you
is that of live data.
And really, I think all data is live data.
All data is going to change over time.
And it may not change on the schedule
that you are thinking about right now.
But we have tools for this now.
We also have this idea of functional reactive
programming, where you can think of things less
as I'm going to call functions on an object and change that
object.
You can think of it more as information
flowing through your system, and you're
kind of like-- you're having the components of your system
grab the data and look at it and produce different data that
goes out the other end.
You can think of this as data streaming around
in your application.
So Dart and Flutter make it really easy to do this.
You've got a great Streams API, the Dart Streams API.
It's full of rich operators.
If you want a formalism for creating snapshots of data
as it changes, you can use Redux.
Brian Egan's got a talk about that tomorrow.
The next Lightning Talk also is partly about Redux.
And if you want an even richer set of operators,
you can use observables with the Rx Dart library.
The author of that is here at the conference.
And once you have a stream of data,
you can use the Flutter StreamBuilder
widget to render that data in a pretty straightforward way.
I'm not going to go over all the details,
but the main thing is you can pass it a stream,
and the StreamBuilder widget will
take snapshots of the data coming out of that stream
periodically, whenever the data changes,
and pass it to your supplied build function.
So you can build a widget from it.
So you don't have to like keep state inside of your Stateful
widget.
You can just assume that you're being
handed the next state that your widget needs to render.
So don't lie to yourself.
The truth will set you free.
Oh, wait.
It's not.
I've got one slide.
OK.
Here's the real truth.
Smalltalk, even though the user model was
you are operating on objects, what
they were doing as you made these changes is
they were writing these changes down to a log file.
So you could take the base image in this log file
and reconstitute your state.
So even if you go all the way back to 1981,
there was still this concept of a stream of data,
and the stream was authoritative.
That's it.
Thank you.
[APPLAUSE]