1 00:03:15,742 --> 00:03:17,822 --People are not important -- 2 00:03:18,837 --> 00:03:23,331 --There are no people in technology, just replaceable components -- 3 00:03:23,331 --> 00:03:27,531 (Laughter) 4 00:06:15,770 --> 00:06:17,220 Alright let's do this. 5 00:06:21,039 --> 00:06:25,954 Alright, I'm going to tell you about what Rust is, 6 00:06:25,954 --> 00:06:29,064 why Rust is a part of Mozilla's work 7 00:06:29,064 --> 00:06:32,054 and when it's going to start being a part of Mozilla's work. 8 00:06:32,557 --> 00:06:33,317 Let's begin. 9 00:06:33,863 --> 00:06:36,023 So Rust is a new programming language 10 00:06:36,029 --> 00:06:40,029 that has been created inside Mozilla 11 00:06:40,651 --> 00:06:42,291 and shared with the outside world. 12 00:06:43,497 --> 00:06:44,869 The goal of it 13 00:06:44,869 --> 00:06:45,659 is basically 14 00:06:46,270 --> 00:06:48,730 anytime when you traditionally 15 00:06:48,733 --> 00:06:50,333 as a developer have 16 00:06:50,815 --> 00:06:51,860 reached for C++ 17 00:06:51,860 --> 00:06:55,344 because you needed certain guarantees about performance for example 18 00:06:55,344 --> 00:06:57,310 we want Rust to be a viable alternative 19 00:06:57,310 --> 00:06:58,475 in every single case. 20 00:06:58,475 --> 00:07:00,750 There should be no reason to choose C++ 21 00:07:00,750 --> 00:07:01,900 over Rust 22 00:07:02,625 --> 00:07:04,355 in the ideal future. 23 00:07:07,172 --> 00:07:09,298 So it began as a side project 24 00:07:09,298 --> 00:07:11,366 of a Mozillian named Graydon Hoare 25 00:07:11,366 --> 00:07:13,939 back in before 2009. 26 00:07:13,939 --> 00:07:16,030 He started working on it full-time 27 00:07:16,030 --> 00:07:17,580 in 2009 28 00:07:17,580 --> 00:07:20,880 because Mozilla saw the ideas that he had and said 29 00:07:20,880 --> 00:07:23,162 "We can see how we could put this into Firefox... 30 00:07:23,162 --> 00:07:26,390 ...and make the product better if we actually had this language". 31 00:07:26,390 --> 00:07:30,356 So that's when we started investing time and resources into it. 32 00:07:31,543 --> 00:07:32,883 Fast forward a few years 33 00:07:32,888 --> 00:07:36,876 we now have a team under the Mozilla Research umbrella 34 00:07:36,876 --> 00:07:39,146 who's working full-time on improving the language 35 00:07:40,027 --> 00:07:44,037 and we released version 1.0 last year 36 00:07:44,041 --> 00:07:46,531 and every 6 weeks we now release a new version 37 00:07:46,541 --> 00:07:48,441 so we just released 1.13 38 00:07:49,302 --> 00:07:51,271 and there is a large community 39 00:07:51,271 --> 00:07:53,411 around the language now 40 00:07:54,106 --> 00:07:56,029 so not only do we have developers 41 00:07:56,029 --> 00:07:57,429 working in Mozilla on it 42 00:07:57,527 --> 00:08:00,520 some of those developers are part of what's called the Core Team 43 00:08:00,520 --> 00:08:03,474 and those are the people that decide the future of the language 44 00:08:03,474 --> 00:08:06,124 and help shape where it's going as time goes on 45 00:08:06,525 --> 00:08:08,104 so in addition to our employees 46 00:08:08,104 --> 00:08:09,454 we have volunteers 47 00:08:09,463 --> 00:08:11,417 and employees from other companies 48 00:08:11,417 --> 00:08:14,772 that are now depending on Rust for their products 49 00:08:14,772 --> 00:08:17,221 and they're helping shape this ecosystem 50 00:08:17,221 --> 00:08:21,260 which then has a large number of libraries 51 00:08:21,260 --> 00:08:23,540 that are being developed by people 52 00:08:23,540 --> 00:08:25,397 who are enthusiastic about the language 53 00:08:25,397 --> 00:08:28,877 it's got a lot of downloads happening since the last time I gave this talk 54 00:08:28,877 --> 00:08:32,208 there've been 10 million more downloads and 300 new libraries published 55 00:08:32,208 --> 00:08:34,990 so there's a lot going on, there's also the friends of Rust 56 00:08:35,003 --> 00:08:38,253 which I'll show you 57 00:08:38,269 --> 00:08:42,542 there is a page showing lots of different companies that've told us 58 00:08:42,542 --> 00:08:45,202 "Yes, we are relying on Rust in production... 59 00:08:45,202 --> 00:08:49,190 ...we are very excited about its prospects". 60 00:08:49,723 --> 00:08:51,933 So, lots of cool things going on there. 61 00:08:58,297 --> 00:09:00,887 So the reason for Rust 62 00:09:00,887 --> 00:09:04,097 is that we have in the past 63 00:09:04,097 --> 00:09:06,745 what 10 or more years of using Firefox 64 00:09:06,745 --> 00:09:08,485 and Javascript in Firefox 65 00:09:08,485 --> 00:09:10,445 sorry C++ and Javascript in Firefox 66 00:09:10,449 --> 00:09:12,439 we've come across the fact that 67 00:09:12,685 --> 00:09:15,215 there are some pervasive problems 68 00:09:15,527 --> 00:09:17,847 that are caused by using C++ 69 00:09:18,971 --> 00:09:22,891 that is writing code that makes use of local threads 70 00:09:22,891 --> 00:09:24,446 is very difficult 71 00:09:24,464 --> 00:09:26,391 it's easy to write incorrect code 72 00:09:26,391 --> 00:09:29,562 and it is very easy to write code which is unsafe 73 00:09:29,562 --> 00:09:31,294 and that translates into 74 00:09:31,294 --> 00:09:33,134 security exploits 75 00:09:33,349 --> 00:09:35,698 things that are stored by governments 76 00:09:35,698 --> 00:09:36,740 and by hackers 77 00:09:36,740 --> 00:09:37,730 all over the world 78 00:09:37,730 --> 00:09:39,230 and used to 79 00:09:39,531 --> 00:09:41,220 steal data from users 80 00:09:41,220 --> 00:09:42,870 and take over their computers 81 00:09:42,882 --> 00:09:44,287 using the browser as a vector. 82 00:09:44,287 --> 00:09:47,737 There's a huge number of these that are released every year 83 00:09:47,747 --> 00:09:51,747 by security investigators 84 00:09:51,955 --> 00:09:53,838 and there's competitions showing 85 00:09:53,838 --> 00:09:57,298 who can pwn a browser the quickest. 86 00:09:57,591 --> 00:10:01,501 So we looked for ways to address this 87 00:10:01,519 --> 00:10:02,693 by creating a new language 88 00:10:02,693 --> 00:10:03,581 and it turns out 89 00:10:03,581 --> 00:10:05,591 that actually both of these issues 90 00:10:05,591 --> 00:10:08,299 make it difficult to write parallel code 91 00:10:08,308 --> 00:10:10,198 that makes use of modern hardware 92 00:10:10,834 --> 00:10:13,683 and writing code that is safe and not exploitable 93 00:10:13,683 --> 00:10:15,398 turns out they can both be addressed 94 00:10:15,398 --> 00:10:18,423 by introducing the concept of Ownership in the language. 95 00:10:18,423 --> 00:10:20,633 So let's talk about what that means. 96 00:10:20,729 --> 00:10:24,199 Ownership encapsulates two ideas basically 97 00:10:24,967 --> 00:10:27,744 it is what the owner of a value is 98 00:10:27,744 --> 00:10:30,036 and whether there are multiple owners of a value 99 00:10:30,036 --> 00:10:33,616 or mulitple users that are sharing a value 100 00:10:34,142 --> 00:10:38,132 and additionally when that value is actually valid. 101 00:10:38,293 --> 00:10:41,463 What is the point in the program 102 00:10:41,463 --> 00:10:44,063 in which it's actually safe to interact with the value. 103 00:10:44,995 --> 00:10:47,005 And so from this we can derive a few rules 104 00:10:47,792 --> 00:10:50,260 that if there is only a single owner for a value 105 00:10:50,260 --> 00:10:54,166 that value can be destroyed when the owner goes out of scope 106 00:10:54,166 --> 00:10:56,856 because there are no ways to reference that value anymore 107 00:10:57,670 --> 00:11:00,036 similarly if a value has only a single owner 108 00:11:00,036 --> 00:11:02,058 that means that it is legal to mutate it 109 00:11:02,058 --> 00:11:05,678 because no one can observe the change to that value 110 00:11:06,439 --> 00:11:07,359 and finally 111 00:11:07,566 --> 00:11:09,776 if you have multiple owners 112 00:11:09,794 --> 00:11:10,681 you need to have 113 00:11:10,681 --> 00:11:11,991 something called Borrowing 114 00:11:11,997 --> 00:11:13,794 which is, you still have a single owner 115 00:11:13,794 --> 00:11:15,309 but other people can observe it 116 00:11:15,315 --> 00:11:17,805 but it cant be changed during that time. 117 00:11:18,015 --> 00:11:21,275 So let's talk about an analogy here, 118 00:11:21,803 --> 00:11:23,873 if I've got a colouring book and a marker 119 00:11:23,878 --> 00:11:25,078 and some friends 120 00:11:25,087 --> 00:11:27,097 we can establish some rules 121 00:11:28,098 --> 00:11:30,718 the colouring book and the marker are my property 122 00:11:30,719 --> 00:11:32,789 so they go with me wherever I go 123 00:11:32,797 --> 00:11:35,354 if I leave no one else can observe the book 124 00:11:35,354 --> 00:11:36,344 or colour in it 125 00:11:36,958 --> 00:11:40,946 however I am able to loan the book to someone else 126 00:11:40,946 --> 00:11:42,786 and that means they're borrowing it from me 127 00:11:42,786 --> 00:11:44,817 that also means that I can't colour in it while they're borrowing it 128 00:11:44,824 --> 00:11:45,774 because that's rude 129 00:11:46,539 --> 00:11:49,169 so they can also choose to lend it to people around them 130 00:11:50,216 --> 00:11:52,546 but that means that if anyone else is borrowing it 131 00:11:52,560 --> 00:11:55,203 they need to give it back to me before they leave 132 00:11:55,203 --> 00:11:56,353 because it's my property 133 00:11:56,353 --> 00:11:57,917 and only I can leave with it. 134 00:11:59,537 --> 00:12:00,377 Additionally, 135 00:12:02,760 --> 00:12:03,994 if I have the marker 136 00:12:03,994 --> 00:12:05,304 I'm able to colour in the book 137 00:12:05,304 --> 00:12:06,349 if I have the book 138 00:12:07,050 --> 00:12:09,070 I can also give the marker to someone else 139 00:12:09,070 --> 00:12:11,789 and that means they can colour in the book if they have it 140 00:12:11,789 --> 00:12:14,070 but that means that I'm no longer able to colour 141 00:12:14,070 --> 00:12:15,930 because there's only a single marker. 142 00:12:16,438 --> 00:12:17,149 And finally, 143 00:12:17,149 --> 00:12:20,339 if I want to leave but I dont actually have the book in my posession 144 00:12:20,339 --> 00:12:24,511 there's a problem, either I need to wait until someone gives me the book back 145 00:12:24,511 --> 00:12:27,036 or I need to actually give it to someone else and say 146 00:12:27,036 --> 00:12:30,012 "OK, it's not my property anymore, ...it's yours to deal with". 147 00:12:32,011 --> 00:12:33,621 So Ownership in Rust. 148 00:12:36,539 --> 00:12:40,544 If we have a type we call a ColouringBook 149 00:12:40,544 --> 00:12:42,238 and it gives us a constructor 150 00:12:42,238 --> 00:12:44,431 that returns a new instance of a ColouringBook. 151 00:12:44,431 --> 00:12:45,271 We can say OK, 152 00:12:45,281 --> 00:12:47,861 here is a variable called a Book 153 00:12:47,864 --> 00:12:49,501 which we will say 154 00:12:49,501 --> 00:12:51,749 stores this ColouringBook value. 155 00:12:51,749 --> 00:12:52,998 That means that we can now 156 00:12:52,998 --> 00:12:54,329 call this Colour method 157 00:12:54,329 --> 00:12:57,249 which will change the Colouring Book in some way, 158 00:12:57,249 --> 00:12:58,166 it'll colour in it. 159 00:12:58,166 --> 00:12:59,557 That's fine, we can mutate it 160 00:12:59,557 --> 00:13:01,277 because we only have a single owner. 161 00:13:03,977 --> 00:13:05,397 So what happens if 162 00:13:05,415 --> 00:13:06,916 someone borrows the Book? 163 00:13:06,916 --> 00:13:09,235 We now have another variable called Borrowed Book 164 00:13:09,389 --> 00:13:10,939 and we use the ampersand 165 00:13:10,942 --> 00:13:13,199 to show that we are borrowing the value 166 00:13:13,199 --> 00:13:15,689 that's stored in this value called Book 167 00:13:15,689 --> 00:13:17,123 - this variable called Book. 168 00:13:17,123 --> 00:13:18,993 This is an Immutable Borrow. 169 00:13:20,486 --> 00:13:22,516 That means that it is not possible 170 00:13:23,013 --> 00:13:25,320 to mutate the original value anymore 171 00:13:25,320 --> 00:13:26,700 because it's borrowed. 172 00:13:27,306 --> 00:13:28,166 So we cannot colour in the book 173 00:13:28,166 --> 00:13:30,446 while it's borrowed by someone else. 174 00:13:31,211 --> 00:13:32,621 This follows our analogy. 175 00:13:34,192 --> 00:13:35,315 The other thing however 176 00:13:35,315 --> 00:13:37,515 is that if someone else is borrowing the book, 177 00:13:37,584 --> 00:13:39,157 they also cannot colour in it. 178 00:13:39,157 --> 00:13:40,489 They don't have the marker. 179 00:13:40,489 --> 00:13:44,639 In this case they only have an Mutable Borrow 180 00:13:44,806 --> 00:13:46,316 so they cannot mutate it. 181 00:13:49,103 --> 00:13:50,623 So we can work around this 182 00:13:50,636 --> 00:13:52,932 by using what's called a Mutable Borrow. 183 00:13:52,932 --> 00:13:53,613 This says OK, 184 00:13:53,613 --> 00:13:55,466 give me the book and give me the marker 185 00:13:55,876 --> 00:13:58,756 and then they have both those elements 186 00:13:58,756 --> 00:14:01,215 necessary in order to actually colour in it 187 00:14:01,215 --> 00:14:02,618 and mutate it in this case. 188 00:14:02,618 --> 00:14:03,988 So we have the ampersand 189 00:14:03,988 --> 00:14:05,629 followed by the Mute keyword 190 00:14:05,629 --> 00:14:06,351 and this means 191 00:14:06,351 --> 00:14:08,656 give me a Mutable Borrow 192 00:14:08,656 --> 00:14:10,156 to the value that follows. 193 00:14:13,308 --> 00:14:15,395 However the thing to note here 194 00:14:15,395 --> 00:14:19,005 is that we cannot use the original variable 195 00:14:19,018 --> 00:14:19,917 called Book 196 00:14:19,917 --> 00:14:21,921 in order to mutate it while it's borrowed. 197 00:14:21,921 --> 00:14:23,634 We cannot have two different people colouring in it 198 00:14:23,634 --> 00:14:25,774 because only one person can colour at a time. 199 00:14:29,735 --> 00:14:32,315 So let's go back to the example we had before. 200 00:14:32,510 --> 00:14:34,250 So we've got a Book value 201 00:14:34,252 --> 00:14:35,544 we're allowed to colour in it 202 00:14:35,544 --> 00:14:37,059 because there's no one borrowing it 203 00:14:37,059 --> 00:14:38,330 then on the next line 204 00:14:38,330 --> 00:14:40,317 we have an Immutable Borrow 205 00:14:41,417 --> 00:14:42,774 and we're not allowed to colour 206 00:14:42,774 --> 00:14:44,195 in the original one again 207 00:14:44,195 --> 00:14:45,115 this is fine 208 00:14:45,126 --> 00:14:46,166 it's borrowed 209 00:14:46,171 --> 00:14:47,451 it can't be coloured in. 210 00:14:48,309 --> 00:14:49,319 So let's fix this 211 00:14:50,300 --> 00:14:52,592 this is where we talk about lifetimes 212 00:14:52,592 --> 00:14:54,255 because remember how I said that 213 00:14:54,255 --> 00:14:56,725 we can figure out when a value is valid? 214 00:14:56,730 --> 00:14:59,390 So this means that if we have a scope here 215 00:14:59,398 --> 00:15:01,408 deliniated by 216 00:15:01,412 --> 00:15:03,233 the curly braces 217 00:15:03,233 --> 00:15:05,653 this means that inside the curly braces 218 00:15:05,662 --> 00:15:08,002 anything that is unique inside there 219 00:15:08,032 --> 00:15:10,292 no longer exists outside of them. 220 00:15:10,298 --> 00:15:12,408 So if we create this Borrowed Book value 221 00:15:12,415 --> 00:15:14,880 and we borrow from the Book value 222 00:15:14,880 --> 00:15:16,859 we have a Mutable Borrow 223 00:15:16,859 --> 00:15:18,179 and that's fine 224 00:15:18,222 --> 00:15:19,529 we can then do something with this 225 00:15:19,529 --> 00:15:21,079 that doesn't require mutating it 226 00:15:21,092 --> 00:15:23,780 we can just look through the Book, we can investigate it, 227 00:15:24,030 --> 00:15:26,203 and that doesn't mutate it, that's fine. 228 00:15:26,313 --> 00:15:29,946 And so previously calling Colour on the original Book value 229 00:15:29,946 --> 00:15:31,045 would've been an error 230 00:15:31,045 --> 00:15:32,139 because it was borrowed 231 00:15:32,139 --> 00:15:34,058 but now the borrow no longer exists 232 00:15:34,058 --> 00:15:37,186 because it is only valid within the scope of these braces. 233 00:15:37,186 --> 00:15:38,676 This is how we can control 234 00:15:38,682 --> 00:15:40,532 the scope of a Borrow. 235 00:15:43,385 --> 00:15:45,603 So finally we can also transfer Ownership. 236 00:15:45,603 --> 00:15:49,017 This is how we talk about giving away the Book to someone else. 237 00:15:49,017 --> 00:15:51,097 By default we can say OK, 238 00:15:52,213 --> 00:15:54,233 we'll create a new variable called Book 2 239 00:15:54,238 --> 00:15:57,218 and it will have the contents of the Book variable 240 00:15:57,652 --> 00:15:59,176 and we can now colour in Book 2. 241 00:15:59,176 --> 00:16:01,839 That's fine, it's not a borrow there's no ampersand there 242 00:16:01,839 --> 00:16:03,804 we are giving control of the value 243 00:16:03,814 --> 00:16:05,204 to another variable 244 00:16:07,206 --> 00:16:08,028 and additionally 245 00:16:08,028 --> 00:16:10,108 if you try to compile this you'll note that 246 00:16:10,108 --> 00:16:12,602 we can no longer interact with the Book variable 247 00:16:12,606 --> 00:16:14,606 because we transfered Ownership 248 00:16:14,607 --> 00:16:15,977 it doesn't exist anymore 249 00:16:15,992 --> 00:16:17,728 the compiler knows this and can say 250 00:16:17,728 --> 00:16:20,206 "Nope, that is not safe what you're trying to do". 251 00:16:21,612 --> 00:16:25,274 And you'll note the link up here actually goes to a playground 252 00:16:25,274 --> 00:16:28,050 where you can play with the Rust compiler in your browser 253 00:16:28,050 --> 00:16:31,857 and there's a sample for this code that you can experiment with there 254 00:16:31,857 --> 00:16:33,385 already prepared for you. 255 00:16:35,722 --> 00:16:36,452 So 256 00:16:37,028 --> 00:16:39,238 we understand Borrowing a little bit better now 257 00:16:39,238 --> 00:16:41,068 especially with the analogy 258 00:16:41,078 --> 00:16:43,088 but how does this actually help in practice? 259 00:16:43,088 --> 00:16:45,779 How does this address the two cases we talked about before? 260 00:16:45,779 --> 00:16:48,418 Using values after they're no longer valid 261 00:16:48,915 --> 00:16:56,055 and writing code that works with multiple threads at the same time. 262 00:16:56,561 --> 00:16:57,271 So first 263 00:16:57,785 --> 00:17:01,075 with Use-after-free problems 264 00:17:02,429 --> 00:17:04,571 those happen in C++ 265 00:17:04,571 --> 00:17:07,551 because you'll have pointers in your code 266 00:17:07,762 --> 00:17:09,433 but the pointers are not associated 267 00:17:09,433 --> 00:17:11,180 with the value they're pointing to. 268 00:17:11,180 --> 00:17:12,770 So you could delete 269 00:17:12,779 --> 00:17:15,057 the memory that they're pointing to 270 00:17:15,057 --> 00:17:17,214 but the pointers are still pointing at that memory 271 00:17:17,214 --> 00:17:19,747 and so if you aren't careful you can end up using pointers 272 00:17:19,747 --> 00:17:21,031 that are pointing to invalid memory. 273 00:17:21,373 --> 00:17:22,423 So in Rust 274 00:17:22,433 --> 00:17:24,263 the compiler is actually tracking this 275 00:17:24,539 --> 00:17:26,819 so it doesn't let you write code 276 00:17:26,836 --> 00:17:28,426 that has the potential 277 00:17:29,017 --> 00:17:32,385 where pointers could point at memory that no longer is valid 278 00:17:32,736 --> 00:17:33,986 and that means that 279 00:17:33,988 --> 00:17:37,108 you're always taking borrowed pointers to values 280 00:17:37,767 --> 00:17:39,090 where the compiler says 281 00:17:39,090 --> 00:17:41,263 "OK. I know exactly how long this value is valid for... 282 00:17:41,263 --> 00:17:45,103 ...because I know what the owner is and therefore any pointers to it... 283 00:17:45,108 --> 00:17:51,358 ...must no longer exist before the owner no longer exists" 284 00:17:54,240 --> 00:17:55,030 and additionally 285 00:17:55,037 --> 00:17:56,459 you can also 286 00:17:56,459 --> 00:17:59,820 because the Rust compiler also tracks outstanding Borrows 287 00:17:59,820 --> 00:18:00,913 you can also say 288 00:18:00,913 --> 00:18:04,543 "OK, we are guaranteed that there's no way to mutate this... 289 00:18:04,543 --> 00:18:08,474 ...while anyone else is borrowing and trying to look at the value" 290 00:18:08,474 --> 00:18:10,403 and this addresses another case 291 00:18:10,403 --> 00:18:12,063 where this can happen in C++ 292 00:18:12,063 --> 00:18:14,768 where you end up changing the value 293 00:18:14,768 --> 00:18:18,652 like reallocating a pointer or something while other things are trying to point to 294 00:18:18,652 --> 00:18:20,471 memory that it was relying on 295 00:18:21,419 --> 00:18:23,940 and as for parallel code with multiple threads 296 00:18:25,450 --> 00:18:27,230 the issue arises with Data Races 297 00:18:27,242 --> 00:18:28,872 where you have multiple threads 298 00:18:28,879 --> 00:18:31,571 that are sharing values and they're also mutating them. 299 00:18:31,571 --> 00:18:34,351 It's the same issue we just talked about basically 300 00:18:34,362 --> 00:18:36,541 where they're not coordinated in figuring out 301 00:18:36,541 --> 00:18:39,776 when it's safe to write to a value and when it's safe to read from a value 302 00:18:39,776 --> 00:18:41,716 because you might get intermediate values 303 00:18:41,716 --> 00:18:43,806 when the write hasn't completed yet. 304 00:18:44,296 --> 00:18:49,776 So Rust addresses this by forcing you to either transfer ownership of values 305 00:18:49,781 --> 00:18:51,346 that another thread needs to use 306 00:18:51,346 --> 00:18:53,926 so that two threads cannot share the same value 307 00:18:53,932 --> 00:18:55,030 or 308 00:18:55,030 --> 00:18:57,960 ensuring that any values that you do share between the threads 309 00:18:57,960 --> 00:18:59,433 abide by certain restrictions 310 00:18:59,433 --> 00:19:01,784 that prevent invalid writes from happening 311 00:19:01,784 --> 00:19:03,654 and invalid reads from happening 312 00:19:03,654 --> 00:19:05,384 so that races can't happen 313 00:19:05,388 --> 00:19:10,978 and it's impossible to write code that is not actually thread safe. 314 00:19:13,479 --> 00:19:14,179 So 315 00:19:14,191 --> 00:19:15,478 how this actually applies 316 00:19:15,478 --> 00:19:17,223 to what we're doing at Mozilla 317 00:19:17,223 --> 00:19:19,616 is that we've got the Mozilla Research organisation 318 00:19:19,616 --> 00:19:22,968 and so part of them are working on improving Rust the language. 319 00:19:22,968 --> 00:19:24,658 However another part of them 320 00:19:24,658 --> 00:19:26,918 are working on building a brand new web browser 321 00:19:26,933 --> 00:19:28,643 because Firefox is not enough. 322 00:19:29,360 --> 00:19:30,950 This one's called Servo 323 00:19:30,960 --> 00:19:33,210 and so we're building it from the ground up 324 00:19:33,479 --> 00:19:35,339 and the reason we're doing this is that 325 00:19:35,339 --> 00:19:36,969 there are decisions that were made 326 00:19:36,969 --> 00:19:38,522 design decisions for Firefox 327 00:19:38,533 --> 00:19:40,213 that were made a decade ago 328 00:19:40,213 --> 00:19:44,203 which are very difficult to change at this point in time 329 00:19:44,217 --> 00:19:45,927 it'd be a huge amount of work 330 00:19:45,930 --> 00:19:48,499 to redesign parts of Firefox we think could be better 331 00:19:48,499 --> 00:19:49,862 but it's also difficult 332 00:19:49,868 --> 00:19:53,337 to verify whether that would be 333 00:19:53,337 --> 00:19:55,927 a worthwhile use of time without actually doing it 334 00:19:55,927 --> 00:19:58,169 so we compromise by creating a brand new browser 335 00:19:58,169 --> 00:20:00,089 where we can actually try out new ideas 336 00:20:00,089 --> 00:20:02,753 and give ourselves a playground to experiment with things 337 00:20:02,753 --> 00:20:05,373 we could do better in Firefox and if they work out great 338 00:20:05,373 --> 00:20:10,117 we can then start transferring them back into Firefox and integrate them 339 00:20:10,121 --> 00:20:11,073 and additionally 340 00:20:11,073 --> 00:20:12,663 this means that we can experiment 341 00:20:12,663 --> 00:20:16,939 with letting out pages 342 00:20:16,939 --> 00:20:18,439 doing that in parallel 343 00:20:18,439 --> 00:20:20,552 rather than all other browsers today 344 00:20:20,552 --> 00:20:22,962 which do them sequentially and single-thread 345 00:20:22,975 --> 00:20:24,415 we can do things 346 00:20:24,428 --> 00:20:25,980 like experiment with the way 347 00:20:25,980 --> 00:20:27,049 that we 348 00:20:27,049 --> 00:20:28,399 redraw things to the screen 349 00:20:28,399 --> 00:20:30,269 and do it more like a computer game 350 00:20:30,865 --> 00:20:33,473 we can do things like change the way 351 00:20:33,473 --> 00:20:35,662 that we're managing memory 352 00:20:35,662 --> 00:20:37,792 for the parts of the web page 353 00:20:37,792 --> 00:20:40,409 so that it's more integrated with the garbage collection 354 00:20:40,409 --> 00:20:41,801 that the Javascript code 355 00:20:41,809 --> 00:20:43,829 ends up ineracting with 356 00:20:43,847 --> 00:20:46,306 so all of this are things that we're doing in Servo 357 00:20:46,306 --> 00:20:48,026 and we're getting some great results 358 00:20:48,032 --> 00:20:49,602 and some of them are already 359 00:20:49,602 --> 00:20:51,958 being integrated back into Firefox. 360 00:20:53,434 --> 00:20:55,504 So we're already shipping foot code today 361 00:20:55,505 --> 00:20:57,495 in Firefox that's written in Rust. 362 00:20:57,767 --> 00:21:00,360 For example we have parts of our Media Stack where 363 00:21:00,360 --> 00:21:06,510 we have code that's just responsible for reading parts of video files 364 00:21:06,510 --> 00:21:09,498 which has been a source of security vulnerabilities in the past 365 00:21:09,498 --> 00:21:11,623 and there's no reason that should be the case 366 00:21:11,623 --> 00:21:13,153 so we rewrite it in Rust 367 00:21:13,153 --> 00:21:14,973 and we get safety by default. 368 00:21:14,979 --> 00:21:16,756 So that's shipping in Firefox today. 369 00:21:16,756 --> 00:21:18,887 We've also got a project called Oxidation 370 00:21:18,887 --> 00:21:21,077 which is a list on the wiki 371 00:21:21,085 --> 00:21:23,946 of all the pieces that we're in the process 372 00:21:23,946 --> 00:21:27,266 of writing in Rust in Firefox today 373 00:21:27,660 --> 00:21:29,270 some of the most challenging ones 374 00:21:29,270 --> 00:21:30,067 that I mentioned previously 375 00:21:30,067 --> 00:21:31,526 the Rendering Engine 376 00:21:31,526 --> 00:21:34,976 the Style System and Layout 377 00:21:34,976 --> 00:21:37,096 those are being integrated into Firefox today 378 00:21:37,096 --> 00:21:38,876 as part of the Quantum Project 379 00:21:38,881 --> 00:21:40,815 and so you can basically expect that 380 00:21:40,815 --> 00:21:42,818 the amount of Rust code in Firefox 381 00:21:42,818 --> 00:21:44,091 will increase over time 382 00:21:44,091 --> 00:21:47,161 there's been a lot of really good results panning out so far 383 00:21:48,190 --> 00:21:50,220 especially for areas where 384 00:21:50,220 --> 00:21:52,332 they shouldn't be security sensitive 385 00:21:52,332 --> 00:21:54,512 that they need to be high performance 386 00:21:54,522 --> 00:21:56,512 those could be great places 387 00:21:56,512 --> 00:21:58,330 for integrating Rust code 388 00:21:58,330 --> 00:22:01,070 because you've got those by default 389 00:22:03,611 --> 00:22:05,568 so if you'd like to know more about Rust 390 00:22:05,568 --> 00:22:06,774 and Mozilla 391 00:22:06,774 --> 00:22:09,437 you can check out the Rust Playground I mentioned earlier 392 00:22:09,437 --> 00:22:12,158 that allows you to experiment with writing Rust code 393 00:22:12,158 --> 00:22:13,196 in your browser 394 00:22:13,196 --> 00:22:14,821 we've got a nice introductory book 395 00:22:14,821 --> 00:22:17,539 that covers everything you need to know about the language 396 00:22:17,539 --> 00:22:19,279 called The Rust Programming Language 397 00:22:19,279 --> 00:22:23,002 which is accessible from the language website and we've got IRC channels 398 00:22:23,002 --> 00:22:26,846 which are designed for both beginners who like to interact with other people 399 00:22:26,846 --> 00:22:29,735 who really want to answer your questions right there 400 00:22:29,735 --> 00:22:32,480 as well as a huge community in the Rust channel 401 00:22:32,480 --> 00:22:35,480 who really adore asking and answering questions. 402 00:22:36,935 --> 00:22:37,645 That's all. 403 00:22:37,645 --> 00:22:38,737 Thank you very much. 404 00:22:39,519 --> 00:22:42,099 [Applause] 405 00:22:42,099 --> 00:22:43,361 Any questions? 406 00:22:48,839 --> 00:22:49,609 Yes 407 00:22:53,159 --> 00:22:56,399 What would be a good way to start contributing or participating? 408 00:22:57,275 --> 00:22:59,020 There's a few ways 409 00:22:59,020 --> 00:23:02,120 so if there are 410 00:23:04,838 --> 00:23:05,608 let me see 411 00:23:05,608 --> 00:23:08,699 if there are libraries that you would like to use from Rust 412 00:23:08,699 --> 00:23:09,919 that don't exist yet 413 00:23:11,297 --> 00:23:14,104 writing either libraries from scratch in Rust 414 00:23:14,104 --> 00:23:16,106 to scratch that itch 415 00:23:16,106 --> 00:23:16,824 very handy 416 00:23:16,824 --> 00:23:18,395 publishing that for the community 417 00:23:18,395 --> 00:23:21,926 or if there are libraries written in C which already exist 418 00:23:21,926 --> 00:23:25,312 which would give you functionality but don't exist in Rust yet 419 00:23:25,312 --> 00:23:26,907 then writing bindings in Rust 420 00:23:26,907 --> 00:23:30,247 around a C library 421 00:23:30,258 --> 00:23:31,668 is very useful 422 00:23:32,766 --> 00:23:35,601 because that allows you to build safer abstractions 423 00:23:35,601 --> 00:23:38,376 on top of things that would otherwise be potentially unsafe 424 00:23:38,376 --> 00:23:40,626 but is really easy to integrate with C code 425 00:23:40,626 --> 00:23:44,673 which is one reason why it's working out so well to integrate Rust in Firefox. 426 00:23:46,871 --> 00:23:49,347 There's lots of other suggestions on the Rust website 427 00:23:49,347 --> 00:23:52,467 of ways to participate in the Rust Community 428 00:23:53,007 --> 00:23:54,607 if that's what you're asking. 429 00:23:58,077 --> 00:23:59,177 Yes Lucy? 430 00:24:15,822 --> 00:24:19,192 What are the most compelling reasons for someone to learn 431 00:24:19,209 --> 00:24:24,859 the language and potentially start participating and contributing? 432 00:24:27,193 --> 00:24:29,243 One thing I've heard is that actually people 433 00:24:29,246 --> 00:24:32,196 who don't already have what's called 434 00:24:32,201 --> 00:24:33,848 systems programming experience 435 00:24:33,848 --> 00:24:36,888 so a lot of experience using C++ for example 436 00:24:36,895 --> 00:24:38,876 one of the lower level languages 437 00:24:38,876 --> 00:24:41,148 people coming from a web development background 438 00:24:41,148 --> 00:24:43,829 people writing a lot of Javascript, Ruby, Python 439 00:24:44,807 --> 00:24:47,520 what I've heard is that people coming from those languages 440 00:24:47,520 --> 00:24:50,620 are actually getting their first experience 441 00:24:50,633 --> 00:24:52,523 doing low level programming stuff 442 00:24:54,074 --> 00:24:57,504 but in a way which is much less daunting 443 00:24:57,510 --> 00:24:59,410 than C or C++ 444 00:24:59,416 --> 00:25:02,811 where they know that the compiler has their back 445 00:25:02,811 --> 00:25:06,139 in ways that the compilers for C++, for example, don't 446 00:25:06,390 --> 00:25:08,229 and it will tell you when you're making mistakes 447 00:25:08,229 --> 00:25:10,284 and it won't let you make those mistakes 448 00:25:10,284 --> 00:25:11,434 which is pretty exciting. 449 00:25:14,993 --> 00:25:17,703 There are two people who I know 450 00:25:17,705 --> 00:25:20,086 who come from Ruby 451 00:25:20,086 --> 00:25:21,269 Javascript backgrounds 452 00:25:21,269 --> 00:25:23,489 who are now putting together 453 00:25:23,504 --> 00:25:25,258 a series of tutorials 454 00:25:25,258 --> 00:25:28,238 for teaching people how to do kernel programming using Rust 455 00:25:29,534 --> 00:25:32,247 with the intention that other people are coming from those 456 00:25:32,247 --> 00:25:34,097 high level backgrounds 457 00:25:34,097 --> 00:25:35,949 and trying this out for the first time 458 00:25:35,949 --> 00:25:39,609 so there's a lot of ways to experiment with things that traditionally has been 459 00:25:39,609 --> 00:25:41,167 rather unapproachable 460 00:25:41,179 --> 00:25:44,279 for large segments of the developer population. 461 00:25:49,791 --> 00:25:52,361 Pretty compelling reason really 462 00:25:52,361 --> 00:25:55,364 and even if you do have experience doing C++ 463 00:25:55,364 --> 00:25:57,134 and lower level things like that 464 00:25:59,139 --> 00:26:02,246 I find that not having to worry about whole classes of problems 465 00:26:02,246 --> 00:26:03,297 you can make 466 00:26:03,297 --> 00:26:06,414 as a developer in those languages 467 00:26:06,414 --> 00:26:07,731 makes a huge difference 468 00:26:07,731 --> 00:26:10,311 it allows you to reason about your code better 469 00:26:10,326 --> 00:26:13,726 it allows you to be more adventurous with your code. 470 00:26:15,255 --> 00:26:34,935 (Inaudible audience discussion) 471 00:26:39,632 --> 00:26:41,392 So the questions was 472 00:26:41,837 --> 00:26:44,147 one of the things people have talked about 473 00:26:45,255 --> 00:26:49,815 is that Rust should be able to make the process of refactoring your code 474 00:26:50,422 --> 00:26:54,252 easier, safer, generally less complicated 475 00:26:54,252 --> 00:26:55,956 and less uncertain 476 00:26:55,956 --> 00:26:58,426 and has there been talk of that 477 00:26:58,431 --> 00:27:00,147 has there been evidence of that 478 00:27:00,147 --> 00:27:00,891 and yes 479 00:27:00,891 --> 00:27:02,851 there's actually a really great blog post 480 00:27:02,858 --> 00:27:04,008 in the past couple weeks 481 00:27:04,024 --> 00:27:05,684 of someone who was 482 00:27:05,689 --> 00:27:07,529 refactoring their code 483 00:27:07,546 --> 00:27:11,696 and the compiler kept pointing out ways in which it would not be safe 484 00:27:11,696 --> 00:27:13,786 to refactor it in that certain way 485 00:27:13,800 --> 00:27:16,032 because it was shared between threads 486 00:27:17,342 --> 00:27:18,597 like he would fix that thing 487 00:27:18,597 --> 00:27:20,507 and it would go down the rabbit hole a little bit further 488 00:27:20,507 --> 00:27:22,610 and say "Oh now this isn't safe anymore". 489 00:27:22,610 --> 00:27:26,280 and was this very compiler guided refactoring session 490 00:27:26,303 --> 00:27:27,493 which he wrote about 491 00:27:27,511 --> 00:27:29,561 and documented top to bottom 492 00:27:29,575 --> 00:27:32,085 and it's great, it seems to just 493 00:27:32,090 --> 00:27:33,008 verify the premise 494 00:27:33,008 --> 00:27:36,968 that this does prevent you from making mistakes. 495 00:27:43,380 --> 00:27:44,950 Alright let's call it there. 496 00:27:44,973 --> 00:27:47,073 Thank you for attending everybody 497 00:27:47,073 --> 00:27:50,283 [Applause]