 Okay So glad that's over. All right, welcome. Thank you all for coming today. I Really have to commend you it took a lot of courage to sign up for this mission this adventure We're about to embark on is not for the faint of heart So if any of you are pregnant or nursing Or suffer from any kind of heart condition Or if your doctor has advised against the eating of spicy foods I Asked that you consider consulting your physician Spiritual advisor psychic medium or nosy next-door neighbor before accompanying me on this journey While we wait to board the ship some of you might want to know a little bit about me your guide before moving forward with this Seafaring journey and I get it. I understand I Don't look quite like a seasoned ship's captain and you're right I'm not I'm Liz. I Used to be a cartoonist. I went to art school. I Drew a few graphic novels a Few years ago. I learned to code. I went to the Flatiron school in New York, and I started working in web development Nowadays I work at Tilda right here in Portland, Oregon Mainly I work on our product skylight, which is a rails profiler that helps developers optimize their rails apps Fun fact we also use rust which is a big part of why I started learning rust in the first place So before we get on the ship, I'll show you a map of where we'll be going right now Our ship is docked at the port of JavaScript just off the coast of Rubyville We'll be sailing the seas of chunky bacon and should be landing at the cargo Bay of Rustlandia in no time So get get on board take your seats no standing No eating or drinking but most importantly no staring at the captain's eye. He's really sensitive about it Say good-bye to your loved ones off we go If you look at your windows to the west you'll notice a beautiful sight some foliage that's native to Rubyville an abstract syntax tree Its nodes are particularly lovely this time of year. You're probably used to seeing these in Rubyville They tend to sprout anytime some code gets thrown into the interpreter just before it gets turned into bytecode So the Ruby virtual machine can run it as you might already know Ruby is an interpreted language So this is more or less what you're used to if you're a Rubyist But in Rustlandia, we'll have to remember to compile our code before we can run it. Otherwise it won't work So when we get there just remember two key phrases cargo build and Cargo run they'll come in handy when we reach the shore and start trying to chat up the locals If you try to just run your code directly like you did in Rubyville They won't know what the heck you're talking about I Also forgot to mention on the way out. You'll notice a big pile of mains Don't forget to take one. You'll need to put all the code that gets run inside of mains very important All right, everybody off the ship here. We are welcome to Rustlandia Let's check out the town. Remember things move a lot faster here. So be careful Check it out. It's the stack in the heap. Let's go inside You're probably used to not giving much thought to memory back in Rubyville Before I came to Rustlandia. I had never heard I had heard of the sack in the heap I knew it had something to do with memory, but I never really understood it Watch how things work at the bar people come in and they give their programs to the bartender and she compiles and runs them Someone wants a fancy whiskey and a cheap whiskey the good stuff is fancy. So we put that in a box and we store it on the heap Because we want it to be able to stick around for a while Even though it's high up and it's a little slower to get to most things in rust are stored on the stack unless you specify Otherwise people in Rustlandia. I guess they really like the cheap stuff Which is why we had to put the fancy whiskey in a box in order to store it on the heap So we run this program the good whiskey gets a spot on the heap at the far far end of our available memory That's like one of those cages in the top And we put a pointer on the stack that points to that spot on the heap next on the stack We put the cheap stuff the cheap stuff gets served up first because it's on top And then we have the pointer to the fancy stuff which the bartender has to go way way up to the top of the heap to get which she does All that sea travel made me hungry Let's check out one of our local eateries. I've heard good things about this one Sir, I can't quite read this menu. I'm used to seeing things like this Class appetizer Chunky bacon. I have no wife no children. I won't have a legacy the only world will know me for his chunky bacon and end Instead I see all these like structs and impulse and like what's this all about, huh waiter? So sorry madam. I know this isn't something you're used to back in Rubyville, but we here in rustlandia we We have no class. No class. I can't believe it. This is heresy How are we gonna get along with her class? It's the one thing separating us from the animals Don't worry. Don't worry at all. You can still get what you need Here's the chunky bacon struck. This is where we define all the attributes we expect out of it flavor chunkiness price, etc So then I can just do something like this and I'll be all set No, no my good lady. That's for that. You need to write an impulse That's an implementation of chunky bacon. So if you want a new instance of chunky bacon, you'll have to write a new method yourself It doesn't just happen automatically. Oh Well, very good. I'll have a I'll have a salad and now a word from our sponsors Me? Yeah, you there. You want to try some rust? You mean the iron oxide produced as a result of a redox reaction of iron and oxygen in the presence of water or a Mercer What do you've been reading Wikipedia? Not that rustful rust like my friend. Oh Yeah, that cool new systems programming language all the kids at school are talking about the very same Well, what about it? Do you like abstraction without overhead? I don't know how about concurrency without data races I think What about memory safety without garbage collection that sounds good. I really don't you'll love rust Welcome to mutability Lake It's a lovely day. So many of our distinguished towns people are out sailing their toy ships Some are fancier than others some are mutable some aren't This one here is a nice one. This one's not mutable So we can't change anything about it, but I can show it to you look how nice if we try to change anything about it though Hey, you can't do that. Oh the compiler is yelling at us. So we know we can't change this one. It's immutable. Let's try another one Cool, this one's definitely mutable. Let's make a few changes before we return it Perfect compiler. What do you think? No? What's the matter compiler? You put wheels on it. It's not a boat anymore. It's a car You said you would return a boat. You must return a boat Okay, okay, I'll take the wheels off. I thought it looked pretty cool though Hey, that look that boat looks pretty cool. You ain't No, that boat doesn't belong to you. Oh Sorry compiler. Who owns this boat? I do. Oh Sorry, can I borrow it? I was hoping to play with it in my bathtub Well, will you bring it back? Of course Go right ahead Don't forget this everyone knows you're just borrowing it Okay, this works. I hope this works. Hey, thanks for returning my boat Compiler does everything look good to you? No, you added a tugboat. That's not okay But compiler these boats are all vectors of strings all I did was push a tugboat onto it a tugboat is a string The tugboat isn't yours and neither is the boat. Yeah, that tugboat is mine Well, what if I just Boom punch the tugboat guy in the face and hit him with a remove Looks like no one owns this tugboat now You want a tugboat on your boat sir? Sure Well, now you have one And now another word from our sponsors Hey kid What? Did you get all that about ownership and borrowing? Huh, that's the cool stuff. I was telling you about before You mean like when you were yelling memory safety without garbage collection at me Yes, you got it. There'll be those so these aren't really problems. I've ever had to deal with Well, let me tell you if you were C++ programmer, you'd be really excited Okay, it's okay Can you just teach me something about rust so the kids at school will finally think I'm cool Sure thing kid. Let's try a less convoluted metaphor. Watch this. Hey again travelers. Have you seen our esteemed library? It's pretty great. You can borrow just about anything as long as you return it They even have this great big pile of books over here that don't belong to anyone You can just take them if you want and then they're all yours Every so often people will come by with donations of books. They don't need anymore. It's great If you want to borrow a book you just use your ampersand If you try to change a book while you're borrowing it Tyler will yell at you and your code won't compile However, if you see something you like in the free pile you can just take it and do whatever you want with it It's yours you there in the back. You had a question Yes, what if the book is a mutable reference? Great question friend. Well, you might very well be borrowing something that's mutable like our collection of coloring books here You can continue coloring them while you have them and you can return them altered only one person can have one out at a time though We also have some exquisite corpse books that are pretty cool every time someone borrows one of these they add a little bit themselves Before bringing it back. I want to borrow the exquisite corpse book Me too. I want to borrow it too No, no more than one mutable reference at a time. You can have it now. We have to wait till he's done before you can borrow it. Oh Man No complaining. Do you want a data race? Do you? No Okay, then you might have noticed how clean and beautiful Rustlandia is and yet you might also have noticed there are no garbage cans anywhere it's it's actually because It's because of that system of borrowing and ownership that Rustlandia is able to do without garbage collection It's a big part of what makes everything so fast and safe here But isn't it annoying having the compiler yelling at you all the time? Hey Don't judge the compiler so harshly look you hurt his feelings. He's not such a bad guy He's just making sure we do everything we do is good before we can run it The compiler is our friend. He just wants the best for us Sure, his advice might be a little hard to understand at times, but once you get to know him. He's a really good guy. I promise And now another word from our sponsors Tonight on WRST, it's the true story of how one statically typed programming language risked it all to figure out how to handle when things go wrong Being and nothingness and error handling Based on the true story If everything goes right the reactor will cool down and the city will be saved But if something goes wrong if this whole thing goes south Well, I guess I'll just do nothing. I mean this seems fine, right? It's just return an option I mean the compiler the compiler feels fine about it, right? Looking good Meanwhile across town The grocery store doesn't have the mustard I like Shut it down. Shut it down. I need my Dijon compiler agrees. Don't you compile looking good? Just because the code compiles doesn't mean it's something you should do Results for when something could go terribly wrong and you need to throw an error option for when it's okay to just do nothing Opposite of what just happened Live it learn it love it errors Hey, welcome back just in time for the last boat to Rubyville I sincerely hope you enjoyed your stay and that you visit again soon If you want to stay a little longer, there are some very nice boxes at the heap Otherwise the boat is ready to board On your way back, we do have some very nice reading material for you if you're interested in learning more about rust I strongly recommend starting with rust by example this online book will lead you through the by hand step-by-step through many examples explaining everything along the way After that I recommend looking at the official rust reference documentation very helpful If you'd like to try your hand at some rust of your very own from scratch There are many excellent exercises available at Exorcism If you have any questions, there is also the rust reddit and the user forums or you can chat on one of the many channels on IRC In preparation for this talk with some help from Yehuda I've been working on a playable text-based adventure game version of this talk in Ruby Which I'm porting over to rust This way you can check out Ruby and rust code side-by-side And you can actually play the game you can check it out at this address the rust code is still in development most of it is on a branch called just rust things but The Ruby version is on master and it's playable. So even though I haven't plugged this story in yet to the game You can play a game And right now it's a little bit random, but anyway, I'm gonna be doing a lot of about moving I'm gonna be working on this a lot in the coming weeks. So feel free to check it out Thank you Last but not least I want to thank Tilda my employer for allowing me to work on the Ruby rust game on company time and Yehuda for working with me on the rust side of the game patiently answering my questions and helping me when I got stuck Once again, my name is Liz. I am on Twitter at underscore Liz Bailey because Liz Bailey was taken And that's it the end