Marijn Haverbeke - The Rust That Could Have Been
-
0:04 - 0:09[ applause ]
-
0:10 - 0:12Yeah, I'm glad so many people
still showed up -
0:12 - 0:15at the very end of the conference.
-
0:15 - 0:20So yeah, I'm going to be talking about
mostly a number of features -
0:20 - 0:23that were part of the Rust language
at some points, -
0:23 - 0:24but no longer are.
-
0:25 - 0:29And, why this is the case
and usually why this is a good thing. -
0:30 - 0:33So, as [Ryan?] said I'm Marijn Haverbeke.
-
0:33 - 0:37If you are into Javascript,
you might have seen my name before. -
0:42 - 0:44Rust has been under development
for a while: -
0:44 - 0:46about ten years now, I think.
-
0:46 - 0:51First - long stretch - was just
Graydon working in isolation and... -
0:51 - 0:55Who knows what kind of ideas and
experiments he abandoned at that point. -
0:55 - 0:59There's not even a like code repository
from that time public. -
0:59 - 1:02so it's like the prehistory.
-
1:02 - 1:04And then, at some point,
-
1:04 - 1:08Mozilla adopted the project
and assembled a team. -
1:09 - 1:12From a little before that point,
we do have Git history, -
1:12 - 1:15and at that point,
everything was discussed in issues -
1:15 - 1:17and mailing lists, and there's...
-
1:18 - 1:19lots of records.
-
1:19 - 1:23I was part of this pretty much -
the initial team - where we... -
1:24 - 1:29Moved from the original OCaml-based
compiler to a Rust-based compiler, -
1:29 - 1:32and we got a bunch more people
involved in the language. -
1:32 - 1:34This was a period of...
-
1:34 - 1:37like, the first real experience
with the language -
1:37 - 1:39and a bunch of people
from different backgrounds... -
1:41 - 1:42giving their opinions on the language
-
1:42 - 1:45and trying to push it
into their favorite direction. -
1:45 - 1:48And, we had a lot of like
experiments and dead ends -
1:48 - 1:51and overhauls and false starts and...
-
1:53 - 1:55just lots and lots of churn.
-
1:55 - 1:59We would sometimes come up with
a breaking change in the morning, -
1:59 - 2:01and then have a patch ready
in the afternoon -
2:01 - 2:03and then convince someone
to merge it later on and then... -
2:04 - 2:08Because there was only one codebase,
we'd just fix everything right away -
2:08 - 2:09and people could continue working.
-
2:09 - 2:11There was some...
-
2:12 - 2:15some trickiness with actually
getting like a compiler... -
2:16 - 2:19that compiles the current code
after you'd make a breaking change, -
2:19 - 2:22so you'd first change the compiler,
then upload a snapshot, -
2:22 - 2:23then change the code,
and then you could - -
2:23 - 2:26everyone could - proceed with
the new snapshot. -
2:26 - 2:29And then, of course,
a year and a half ago - I think - -
2:31 - 2:33the team [cut] version 1.0,
-
2:33 - 2:37and then the process changed entirely,
so now it's like... -
2:38 - 2:39everything stays backwards compatible.
-
2:39 - 2:44It's impressive how seriously they have
been taking backward compatibility. -
2:46 - 2:50Experiments moves like -
[RFCs??] move very slowly -
2:50 - 2:52and there has to be a wide consensus
-
2:52 - 2:55and it has to fit
within the current codebase. -
2:55 - 2:58So, that's a whole different stage again.
-
3:00 - 3:03I'm going to be mostly talking about
the period where I was part of the team. -
3:03 - 3:06which was 2011-2012,
-
3:06 - 3:08and which was probably
the wildest period -
3:08 - 3:13in terms of features cut,
features changed - stuff like that. -
3:15 - 3:17So, it may seem a bit ridiculous
-
3:17 - 3:20that we put so much time into
really complicated features -
3:20 - 3:22just to end up dropping them again.
-
3:23 - 3:28But, I think it's kind of an essential
part of getting a complex design -
3:28 - 3:30like a programming language right that,
-
3:31 - 3:34unless you're a super-genius,
you won't really see in advance -
3:34 - 3:36what the implications
and the interactions between -
3:36 - 3:40the various parts of the system are
and you have to try it and see -
3:41 - 3:44how well you can make it work
and how well it fits into the system, -
3:44 - 3:46and sometimes
you later have to just... -
3:47 - 3:48abandon it again.
-
3:49 - 3:53I think that's part of
a healthy design process for like... -
3:54 - 3:57mere mortals who need to
actually see how something works -
3:57 - 3:59before they can evaluate it.
-
4:00 - 4:04I'm structuring this talk about...
around a number of visions -
4:04 - 4:07that were part of the language
and then dropped again. -
4:07 - 4:12And, I'll try to explain why I think that,
in every case, -
4:12 - 4:15it was a real good decision to drop them.
-
4:15 - 4:18But, it's still interesting to see
-
4:19 - 4:22what the original visions were
and what we did end up with. -
4:23 - 4:28So, these are typestate,
a structural type system and -
4:29 - 4:33lightweight processes,
and finally, garbage collection. -
4:34 - 4:36Let's start with typestate.
-
4:38 - 4:41Typestate is... it was actually
-
4:41 - 4:45an important point in initial
announcements of the language. -
4:45 - 4:47and people were very excited about it.
-
4:48 - 4:51What typestate does is basically
allow you to... -
4:51 - 4:56allow the compiler to know
more about value than just its type. -
4:56 - 4:57So, an example would be...
-
4:58 - 4:59This is something of type [sockets],
-
4:59 - 5:04but we also happen to know that it's open
or this is something of type array, -
5:04 - 5:07but we happen to know...
or say vector in the current terminology, -
5:07 - 5:10but we happen to know that
it's not empty. -
5:10 - 5:13Something like that allowing you to add
-
5:14 - 5:17more safety to your program -
more static guarantees. -
5:19 - 5:23So, when you're programming,
you usually have some mental model -
5:23 - 5:27of why the thing you are doing
right now is... -
5:27 - 5:30is valid - is not going to crash -
-
5:30 - 5:32like if you're not just making
random changes -
5:32 - 5:35and seeing if the [tests pass],
you will have -
5:36 - 5:39some mental model of your... program.
-
5:40 - 5:42And, to a certain degree,
depending on the language, -
5:42 - 5:45you can tell the compiler
about this model -
5:45 - 5:46and the compiler can then check
-
5:46 - 5:49whether you are applying
your model consistently. -
5:49 - 5:53So, the simple case is just types -
that you're actually passing the type -
5:53 - 5:55that you think you are passing somewhere.
-
5:55 - 5:59And, if you don't,
then, instead of finding out at runtime, -
5:59 - 6:02you find out at compile time -
and this is nice. -
6:02 - 6:03There's a kind of...
-
6:04 - 6:08this computer does not have the fonts
that my computer had but... -
6:08 - 6:10Imagine arrowheads on both sides.
-
6:10 - 6:14There's a kind of spectrum
on which languages fall -
6:14 - 6:16in terms of how much
-
6:17 - 6:19you can actually communicate
to the compiler, -
6:19 - 6:21so down on one side,
there's Javascript -
6:21 - 6:24and it's like... syntactically correct.
-
6:24 - 6:26Okay, let's go ahead - let's run it.
-
6:26 - 6:29And then, there's like,
on the... way on other side, -
6:29 - 6:32there's language like Coq,
which require you to actually construct -
6:32 - 6:37a formal proof that your program does
what it's supposed to do - -
6:37 - 6:40that it does so in bounded time,
in bounded space, -
6:42 - 6:46which means you're making
a lot less mistakes. -
6:46 - 6:48But, on the other hand,
it's like a major... -
6:49 - 6:53a major project to write a small program
in such a language. -
6:54 - 6:58And, there is a reason that
not everyone is writing their web servers -
6:58 - 6:59in Coq or whatever.
-
6:59 - 7:01And, Rust kind of falls in the middle.
-
7:01 - 7:04It does have quite a bit
of static guarantees -
7:04 - 7:06and it helps quite a lot.
-
7:06 - 7:11But, it still aims to be ergonomic,
like easy to [program in], -
7:12 - 7:14where you don't have to
-
7:15 - 7:18spend too much time
working on these things. -
7:20 - 7:25And I... one way to see the history
of programming languages is kind of... -
7:26 - 7:29one aspect of it at least is
-
7:29 - 7:33that we've been finding better
and better vocabulary to... -
7:33 - 7:38to describe these things we know about
our program to the compiler -
7:40 - 7:41in a way that's actually convenient.
-
7:41 - 7:43So, if you have a really terrible
type system, -
7:43 - 7:46that's often worse than
no type system at all. -
7:46 - 7:49If I have to choose to write something
in Java or Javascript, -
7:49 - 7:52I'll just take Javascript,
thank you very much. -
7:52 - 7:54But, we're getting better at this,
-
7:54 - 7:56and Rust is making
a big contribution here, -
7:56 - 7:59and like bringing a real,
modern type system -
7:59 - 8:00to the systems programming space.
-
8:00 - 8:03And the ownership model is - I think -
-
8:03 - 8:05just really, really good.
-
8:05 - 8:08I unfortunately wasn't on the team
anymore when this was introduced, -
8:08 - 8:10so I can't take any credit for it, but..
-
8:10 - 8:12I think that this is
the most exciting part of Rust -
8:12 - 8:14and it's exactly this kind of thing
where you... -
8:14 - 8:18where the compiler knows
what you're trying to do and -
8:18 - 8:21tells you when you're
violating your model. -
8:23 - 8:25So, back to typestate.
-
8:26 - 8:28It looked somewhat like this.
-
8:30 - 8:32You could define [predicates],
-
8:32 - 8:35which is this "pure function not empty"
at the top -
8:39 - 8:42The extra information
that the compiler had about your values -
8:42 - 8:45came in the form of this predicate [ ... ]
-
8:45 - 8:49But, these were actually just predicates
written in normal Rust code -
8:49 - 8:50that were supposed to be pure.
- Title:
- Marijn Haverbeke - The Rust That Could Have Been
- Description:
-
This talk will describe a number of language concepts and features that were in the pre-1.0 Rust language at some point but were ultimately abandoned, such as typestate, garbage collection, structural types, and a more or less classical object system. I’ll go over the reasons they were abandoned, and try to convince you that the Rust we have now is the best Rust yet.
---
For more go to https://rustfest.eu or follow us on Twitter: https://twitter.com/rustfest - Video Language:
- English
- Duration:
- 31:11
Sasha Harrell edited English subtitles for Marijn Haverbeke - The Rust That Could Have Been | ||
Retired user edited English subtitles for Marijn Haverbeke - The Rust That Could Have Been | ||
Retired user edited English subtitles for Marijn Haverbeke - The Rust That Could Have Been | ||
Retired user edited English subtitles for Marijn Haverbeke - The Rust That Could Have Been | ||
Retired user edited English subtitles for Marijn Haverbeke - The Rust That Could Have Been |