Ah, here we go.
So I started out a long
time ago, getting used to C.
We didn't have containers,
but we had something very familiar.
We didn't have string,
but we had something
like a vector of care;
a vector of care with a
monotonic sequential allocator,
and an integrator for them.
But we called them malloc
arrays and pointers.
(laughter)
And pointer operations were awesome.
If you look at the
original source for Unix,
they were amazingly concise.
But they were amazing and horrifying.
I mean, this little equation right here
has 2 different pieces of state
being modified on the left
and one on the right.
You had to really pay
attention to what's going on.
So I was running a raytracer,
and I had something that was essentially
a vector of vector of polygons,
but it was malloc and
pointers to pointers.
I went through and
counted how many polygons
ended up in each cell with my grid.
I allocated all the cells and
then I had to fill them in.
So the code did a whole bunch
of three-dimensional math,
scan, converting the polygons.
And at the end it needed to
fill the polygon pointers
into this data structure.
So using all my Jedi powers
and everything I'd learned about pointers,
I wrote that.
(laughter)
Three pieces of state being modified
on just the left-hand side.
Crashed GCC at the time.
(laughter)
So they say there's supposed to be
two audiences for your code;
well, neither of them could read this.
Yeah, that was my first education.
I moved on to inheritance in C++.
I was writing a proxy
for instant messaging,
and I had a server and a client,
and I was in the middle there.
The messages would come from the server
and I would catch them and
parse them and pass them on.
And messages would come from the client.
You see a little symmetry here.
So I wrote a class socket;
everyone has to write one
of those back in the 90s.
And the message processor that handled
the particular protocol
of the messaging system,
and it had a socket.
And I made one for the server side
and one for the client side.
And then what do you need to do?
You hook them together.
(laughter)
It worked ...
(laughter)
But I don't recommend it.
I was also needed to
parse regular expressions.
What's the best place to get
perl regular expressions?
Well, we'll get 'em from perl.
We'll call 'em from C++.
And you know, C++ is great
for managing resources,
thanks to DRES,
or you might know it as RAII.
There's a lot of ceremony.
So, we'll use a code generator.
And we can write that in perl,
and then we'll show how
smart we are by writing
a special makefile rule.
So I had this makefile
that took .cppp files
and turned them into .cpp.
Right in the same directory
as the original .cpp files.
Then I was really cooking.
(laughter)
Now get to templates;
it can only get better, right?
You know, STLs,
This is back in the
days of Visual Studio 6;
you didn't really use STL still,
so you wrote your own list class.
Usually it was intrusive,
so you could use the curious
recurring template pattern.
And, in sort of the 98
style that you saw from STL,
even though you couldn't use it,
this didn't look anything
like I was used to
when using pointers in C.
I would not call this concise.
What I wanted was something like
I would do when I used pointers,
except that now you're making copies,
and post increment is just broken in C++.
You know, maybe if the language
had gone a different way
we could declare reference,
but you can't assign references
and you still can't post increment.
So I thought about this,
and I thought about this,
and I thought outside the box,
and then I thought way outside the box.
And then I thought Alice
in Wonderland style,
and I just created my own definition
of what pre-increment meant,
and created this entire alternate reality
where you could beautifully
describe what you wanted to do,
as long as you didn't know
what pre-increment meant.
(laughter)
Don't be Humpty Dumpty.
So engineering, we learn from our mistakes
and we learn from the mistakes of others.
I encourage you to look at your own code
as you progress in your career.
Try to find times that you
made a choice that didn't work
and see if you can
learn from that as well.
Thank you.
(applause)
