Rebuilding in Rust for Good Reason with Eve Porcello === [00:00:00] Hello and welcome to PodRocket, a web development podcast brought to you by LogRocket. LogRocket helps software teams improve user experience with a session replay, error tracking, and product analytics. Try it free at logrocket. com. I'm Tejas and today we have Eve Porcelo here to cover her latest conference talk, Rebuilding in Rust for Good Reason. She's the co founder of Moon Highway, a curriculum development and training company based in , Northern California. Welcome back, Eve. Thanks so much for having me. So it's a real pleasure. I'm glad we get the chance to do this. We've touched base, at conferences and we've hung out here and there, but it's nice to be in, in a different format for once. I'd love to talk about your talk. Especially because I work daily with some really good friends on Rust things literally every day. And I'm really eager to cover, rewriting things in Rust, even writing things in Rust. What do people write in Rust? Do they do UIs? I don't think so, but I'd love to talk more about these things. But before we get into all of that do you mind telling our listeners a little bit about your background and experience Absolutely. So I've worked for the past 11 years with [00:01:00] Moon Highway. We're a JavaScript and Rust and GraphQL and all sorts of things training company. We also build. Tools for teachers . So, instructor notes, apps, and things like that. And I love being part of the community through conferences and creating videos and things like that too. Awesome. So you mentioned Javascript, and then GraphQL, and then Rust. And these three are really different, right? Javascript is primarily, it's a thing that runs in the browser, and sometimes on servers with Node. js, or I guess BUN more so nowadays. And GraphQL being this language specification, really, . For client server contracts and then there's rust. How do these three fit together? And was rust added later to Moon Highway? What is the trajectory of JavaScript, GraphQL, and Rust look like? Yeah, we also always started in the JavaScript realm, teaching a lot of React classes and JavaScript classes as well. We [00:02:00] then noticed that a lot of our clients were trying to rebuild a lot of their developer tools using Rust, and their developers were struggling to implement those projects just because , They were working in JavaScript all the time and didn't really have the dedicated time, to devote to learning Rust and getting involved there. So that definitely has been a later addition, just based on kind of the trends that have been emerging in the community. Y you mentioned a number of people clients, I think was the word you used, building stuff in Rust. More and more. I'm curious what were they building in rust and what do people typically build in? And so we see things like Like TurboPack, for example, which is Vercel's kind of rewrite of Webpack into Rust. Is it mostly build tools? Or, yeah, I wonder if we could speak a little bit to what what people build with Rust. Yeah, that's a great example of one. I think a lot of tools that developers don't really [00:03:00] interact with as much. So build tools. A great example is Apollo GraphQL recently rebuilt a tool for Apollo Federation. It used to be built in Node. js. Now it's called Apollo Router and is built in Rust. So basically what that does is it Pulls together all of these different APIs that you have working out there and Rust just is a better, probably choice for that because they've found it works a little bit faster, runs faster. So all of those things where performance is a really big deal, like TurboPack, right? Where we're we're wanting those build times to be much, much faster. It's a really nice choice for those types of things. So what I'm hearing is we build things, usually things that run on like systems. So not necessarily in browsers. Or I guess you could do Rust in browsers using WebAssembly. I've never done it personally, but that's probably possible for some, but seems tricky. [00:04:00] Yeah, So there's, it sounds like the big value proposition really is performance, because Rust is this language that is statically typed, but above and beyond statically typed, there is no how do you say, interpretation at runtime, right? It's compiled And then the compiler, by the way, I'm spitballing here, so I'd love it if you could correct me where I'm wrong. So there's this compiler that catches your issues before the application builds, and once it's built, you know that it's going to work as expected. And it runs not in a virtual machine like JavaScript does, but it runs directly on the CPU cores. Like C. And it has its own primitives for memory management similar to malloc memory allocate NC and free. Is that similar? How close? How far am I? you're right on. I think you're exactly right. So we have the ability to install that directly. We also Have the ability like, like it or not pros and cons of this, but to see our errors right away, when you're trying to compile [00:05:00] something, it'll tell you, Hey, and the rest compiler is actually pretty communicative and clear about what's going on, which is. Pretty great coming from a lot of JavaScript work over the years. So we are having the ability to see what those errors might be and deal with them before they even roll out at all. That's so fantastic. Can I have a question for you? That's, I think, really on The minds of multiple people. And this is because I think multiple people are similar to me. Which may be wrong, but the question I've had for years, right? I was I had the privilege of being at JSConf EU, and I think it was 2017 or 2018, where I think it was either Lynn Clark from Mozilla or Ashley Williams from um, also at the time Mozilla now has Axo. dev, really great company. But they did this talk called Baby's First WebAssembly Module, which is, you write Rust, you compile to WebAssembly using Cargo, we'll get into Cargo and things. But that's where I saw Rust for [00:06:00] the first time, because it was at a JavaScript conference interacting. With JavaScript and my background, as was yours from what I can gather in our discussion is JavaScript. Like I started with JavaScript. A lot of our listeners started with JavaScript and frankly, JavaScript. I feel is the language that is easiest or maybe the most, how do you the most welcoming just in that there's this like instant feedback loop you open a browser console and you just run stuff. You could literally like alert or prompt and build a program in the browser. So, because this is the theory anyways that a lot of the listeners are currently in JavaScript. And based on an episode like this, I'm probably thinking about Rust. I'm curious, what would you say is the best way for JavaScript developers to get into Rust? The way I learn is through building things, maybe a greeter or a hello world. So the way I learned JavaScript, I'm not even making this up, was I started with alert in the console, and I was like, whoa, a dialogue. And then I moved to prompt. And so it was like, enter your name, and then you type your name, and then it just console logs the response, right? This is literally how I learned JavaScript. I'm curious if there's something like that [00:07:00] in Rust that people can maybe take their first steps, and then progress from there. Totally. I love prompts. Prompt is our friend. We had so much fun. Yeah. And the feedback loop was really exciting. . So I think one of the best ways to get involved is there's a rust playground that runs in the browser, like code sandbox or code pen that it already has a few different. Lines of code there for you, you can start to mess with those in a good way print whatever you'd you can start getting acquainted with writing functions in Rust. So I always recommend that people versus installing it and dealing with kind of the compiler things that can be a little bit daunting. Just trying to run things in the browser and playing around with existing code blocks is a good way to say, Hey, I know what a function is in JavaScript. This is what it looks like in Rust. I can guess that The FN keyword [00:08:00] probably means function. I can start to make sense of the syntax. As soon as you start to mess the syntax up, which happens right away, for me at least, you'll find out right away, right? So, it'll tell you, actually, you need a semicolon on every single line in Rust, unlike JavaScript. So, using that browser tool, and you can find it from the Rust documentation, it'll take you right there, but it's called the Rust Playground. That's... Usually where I point people to just to get that quick feedback about what the language is doing and what that syntax looks like. Awesome. That's really great. One really interesting. So I'm, I tend to be A really big nerd. And this thing you said about JavaScript having optional semicolons, I found out that they are not optional. It's just that when you leave them off, they're inserted on the fly after the fact, I love it. Yeah, that's one of those things wow. Okay, that's really useful. So we can go to the Rust playground and start playing and [00:09:00] building things. And, so, if we translate the model of applications we build with JavaScript today, a lot of applications are essentially, you render some output to some thing that renders output, either a browser window or a terminal, which I'm assuming Rust would probably prefer the terminal. We could maybe get into things like U, et cetera, later, but that's Y E W, not U U. Anyway And so my question is, most things just render something and then interact with things. So we'll do like network I. O. to some A. P. I. endpoint or some database. So there's rendering, which is, CPU bound, and there's I. O. to fetch data or something, and then or even from the disk, and then put that back on the screen, so there's more CPU. I think this is maybe an oversimplification, but this is basically what most applications do. The print statement in Rust is responsible for putting stuff, on the screen. I'm curious about the I. O. side of things. Equivalents, for example, in Node. js would be things like fs. readfile. Or JavaScript in the browser would have the fetch API. I'm curious, does Rust have similar primitives built into the [00:10:00] language? Or is there? A standard library of sorts that JavaScript doesn't give you. It's more the runtime and JavaScript giving you these things, right? So Yeah. So Russell give you that. It will give you a standard library of like interacting with the file system, input, output stuff, reading from the CLI. Rust is probably the smallest app to build with Rust that really gives you a sense of the language and the capabilities is... Literally just to build some sort of CLI, you talked about prompt before we could build some little question app to collect some data from the user, that sort of thing. So I would probably start there just because it's more fun, right? It's interactive. It's allowing you to really get an understanding of what is possible, what is available. So a lot of those things you would see in Node. js. Or Dino or Bun [00:11:00] or whatever the thing is that you want to use today. But the idea being, instead of having to build a whole library for interacting with the file system, that's something that we're probably going to need to do. So we can write to a file, append a file, all of those good things. And we can incorporate that from Rust itself. Beyond the standard library that's provided, there's something Well, there's a whole range of various, as you might expect, libraries that you can dig into from the community so you can build on top of those standard functions or you can just build You can just start anew and use whatever that library provides to you. So yeah, pretty much everything that we would like to do in another language again, not talking as much about the UI, but the interacting with the file system or [00:12:00] making requests for data, all of that is pretty well handled in Rust. So you can follow the guidelines that are provided. that's really awesome. You've given me because you said prompt, this was the thing that really led to my ears perking up and gave me like a light bulb moment. Cause based on prompt, I could maybe build, and I think our listeners could build. A little almost like a trivia game, but CLI based, right? So you run this app and then you get a question and then you answer it. And then you answer like 10 questions. Then you can score at the end. Whoa. That's a really fun, like way to totally. Yeah. Super fun app. I like it. I'm stealing that one. Yeah. Does the Rust playground, I guess it supports things like prompts as well. I'm asking because these online in browser types of things Yeah, we would have to probably create that as some sort of different variable. I hear what you mean though. Like as far as interacting with the file system, we might have to, we might have to [00:13:00] download rust and use it that way. But I would love to know. If some listener wants to send me a message, if there's a, another playground tool that might be a little more dynamic like that, or we can all build it together maybe That's awesome. Yes. If somebody's listening and wants to share that we'd recommend at pod rocket on X and let us know. Okay, awesome. So again, to recap, you and moon highway started with JavaScript and rust became a thing that You'll work with later on. I'm assuming there was some type of learning process and transition time. What was that like? And we've talked about the positives about rust, the fact that things happen at compile time, so they don't happen at runtime. The beautiful error messages that really guide you the lack of automatic memory management, but there is still prevalent idiomatic error management, like the things work a lot easier than other languages like C, etc. At least to us. I'm curious, in contrast to these positives [00:14:00] what was the thing that really tripped you all up every single time or fairly often when you all were learning or transitioning to Rust? I think one of the tricky parts was There are a lot of great resources for learning Rust, but I didn't have that background in C. I didn't have that background in memory management and allocation and things like that. So I think that was ultimately good for me because it allowed me to learn about those things that are always going on behind the scenes, like JavaScript throwing semicolons in there anyway, or the things that happen to, make compilers work and things I just used in a JavaScript sort of way, but didn't really maybe understand as deeply. So that was a little bit daunting. And also the syntax seemed a little bit more hectic in the sense that we're creating a variable, that variable must [00:15:00] have a type. It's going to have a type that is any number of types, not just a specific Small Javascript type and by that all the different types of numbers or character types. But I was learning Rust a little bit before I learned TypeScript. So I think if you are someone who has learned TypeScript over the past however many years, TypeScript has been around. I think it will be a more seamless transition for you just because you're already used to when you create something thinking about what that thing is versus just like we'll create it and figure it out later. So, yeah, I think the syntax was a little bit tricky as well as just learning. More computer science things that I probably should have known before anyway, so, It's, good to know those things whenever they come to you. Yeah. [00:16:00] Yeah. I I also full confession. I also don't know and didn't know a lot of computer science things and Rust was the way I learned it. And I have to give a big shout out actually to the Rust book. I'm not sure who wrote that. I think it was Ashley Williams or Steve Klabnik or both of them or some collaboration, but it tremendous resource. I think it's still available to this day. And it's honestly, I think the best documentation work I've ever seen. Very close. I think Astro docs come very close, but Oh my gosh. Rust book, really good resource. So you mentioned something really interesting. You mentioned if you're coming from TypeScript, your transition might be. A little bit more seamless, because you're used to having a compile step, you're used to having, you're thinking about what is this? Is this an array? Is this a tuple? Is this a number? Rust's type system I've heard and experienced that is, it is a little bit more complex. You alluded to this by saying, you referenced like basic JavaScript types like number and Rust seems to have more complex types of numbers. What's with [00:17:00] that? Could you expand that a little bit for our listeners? sure, so, yeah, a number is not a number. There are many different, I know, right? There are many different types of them and it all has to... to do with creating the smallest possible container for that variable. So depending on what number you are trying to create, you're trying to be as efficient as possible about the little compartment that will go in within your program so that you're not taking up more room than is necessary. So there. There are so many the documentation goes deep on these about the exact specifics for Unicode unsigned integers, all these things, so I don't have them all memorized, but what's nice about the book, as you mentioned, and the documentation is that'll walk you through all of those, but yeah, it really has to do with being [00:18:00] as specific as possible so that Memory so that the program can be as small as possible, because sometimes you're running rust on some little IOT device that doesn't have a lot of space and you're literally thinking about how to make that the fastest possible thing. So. The intentions are good, but it can be like, Oh my gosh, are you kidding? I have to learn all this stuff. I have to pick the right thing. It's so stressful. How do I do this? But as you get more comfortable with the language, it will feel like that's there to help you versus just there to torture you computer science style. that's so funny. I want to come back to this before I do. I'd like to take a quick break and plug log rocket once more. For those listening, log rocket offers session replay, issue tracking and product analytics to help you quickly surface and solve impactful issues affecting your user experience. With log rock, you can find and solve issues faster, improve conversion, adoption, [00:19:00] and spend more time building a product and less time putting out fires. So, thanks to a lot of rocket for. We're making this podcast even possible. Eve, you said something, so you keep dropping these like profound bombs and I love it because it's great jump off point for a really good conversation. You mentioned in Rust, a number is not a number. And I love that because it really isn't. It's an allocation of bytes. And I like how I want to really take a moment and applaud here what you said, because it, Thank you. Speaks to the mechanism of why Rust is the way it is, and to JavaScript developers as you and I are and were I, to be fair, I don't identify as a JavaScript developer anymore but mainly because TypeScript, I can't even touch JavaScript. Anyway, discussion for another time, but You spoke to the mechanism of why it is the way it is. Because like when I was learning Rust, and I'm sure you can relate, right? We think about numbers and we see like I32, U64. What is this? And why is it not number? And you said it so eloquently. It's because We care about [00:20:00] memory and we care about allocating the right amount of bytes for these things. And we care about not occupying, and you said, I think you said occupying too much space. I think that's brilliant. Mainly because also with JavaScript, we're not trained to think about memory. We just go, we set timeout without cleaning it up. That's the wild west we came from. Don't you know where we're from? Yeah, exactly. And so I really appreciate that. Similarly there's this mechanism in Rust called and the ampersand has special meaning in Rust. And this is something that a lot of people from JavaScript coming into Rust have questions about. I'm curious if you could summarize maybe one, two sentences what is that? And why is a string not a string sometimes in Rust? So basically, the ampersand has to do with when you're creating a variable in Rust, you can use the ampersand to say, I want to borrow from this value and use it in another place. So, You can [00:21:00] share that reference to something without having to create it again. Which seems confusing only because it's very confusing. So that again is very tied into our obsession with the smallest possible Program because we care about its size simply for performance. So it feels Oh, I have to do this. This is so confusing. What does the ampersand mean? How do I square this? And it really, we always want to be thinking about how to refer to something versus creating it again, because that would be less. Use of memory that feels again, for a JavaScript developer like me, who builds a lot of builds a lot of apps that don't have huge numbers of users. It feels like who cares about that, but it really puts you in [00:22:00] the, it puts you in the mindset of, thinking through performance all of the time and thinking through being as careful as possible with that. And there's a lot of value there. Because it means your programs will run faster. It means that they're not going to be as expensive to run. All those things. Expensive in money and expensive in time. So, yeah. It's tricky business, but useful. I think that's really well put. And I think. I think the real friction for us coming from JavaScript is that I don't know about your experience. I can't speak to that. But for me, I was never trained to think about performance or Yes. And I think that's a systemic problem in our industry is we just and I think it's a consequence of this rapid feedback loop. It's Oh, I can create an alert in the browser. I'm basically a full stack developer. And. I think that's amazing because it's, there is, the barrier to entry is so low. But also I think what the dark side of such a low barrier to entry is we're not [00:23:00] trained in performance or in accessibility. And as a result things left and right where recently v0. dev by Vercel was found to be inaccessible and there's like a lot of drama around this kind of thing. Yeah, it's a very complex, I'd love to see someone, someday talk about the goods, the bads and the solutions about that, but I was wondering, you mentioned the way the ampersand works. And I want to say it back to you just to make sure I understand it myself. You mentioned the ampersand is instead of creating a new thing, referring to an existing thing. And so, for example, a string, if I have a string, hello It's if I wanted to reference the exact bytes in memory of that particular string, I would use the ampersand versus if I made a new variable also assigned the value of hello as a string that would create a new hello string in memory. It wouldn't be the same. So my question. First of all, is that correct? Is that accurate? Absolutely. Said very perfectly. Awesome. Are there parallels here between JavaScript's JavaScript sometimes has this like copy by [00:24:00] reference or copy by value type of behavior where an object is never equal to itself, but an assigned object is equal to another assigned object of the same time. I'm butchering this. I apologize. I'm hoping you pick up what I'm laying down. No, I do. I think yeah, when we're referring to other things, we're thinking, I think the part to zero in on there is the value part, so we're thinking about how can we How can we utilize that value again, and make sure that we're well, first of all, reusing it throughout, which is the good part, but also making sure that we are not changing that value, mutability is a huge conversation we could get into, and rust as well but this is like a combination of the two, where we're referring to something, we're Utilizing its value [00:25:00] and we're being very strategic about how many times we're creating different values and variables. All so that our applications can be as efficient as possible across the widest variety of devices as possible. So ultimately, this is an accessibility topic. Okay, so what if There's a lot of people who are creating internal only tools that are not meant for mass adoption and things. In this case, would it make sense then for a Rust application to still care and be as meticulous about performance and smallness, as it were, or should a developer just consider you know what, I'm just going to allocate U64 for this, I know it's going to be a small number forever, but I'm just doing 64 bytes because I don't care, because I came from JavaScript. I'm curious what do I do? Or what should you do? Yeah, I think. I hear what you're saying, I think because we have the option to do the right thing and use the right size container for the right size value it's [00:26:00] always nice to attempt that, but I totally hear what you're saying, which is as you are If you are building something internal and small, maybe you don't want to think about those as much, but I think that's a very, it goes back to what you said about not thinking about performance and accessibility when we learned Javascript, right? So, That becomes an afterthought. So later on when it rolls out, we realize, Oh no, people are going to use this. So we have to think about all this stuff later. So I would always say best case scenario, assume someone. Assume more people will use it than you think, or you might go to a different company and someone will judge your U64s everywhere I so love That That is so good. I love assume, always assume more users than intended because it's such a tricky thing, at least in my [00:27:00] experience and thoughts around teaching, right? Because I honestly, I want the world to collectively migrate from JavaScript to TypeScript. I just see so much value in TypeScript counter to DHH, right? I don't really mind the The compile step or the time that would take to build because like the value you get is no, or as few as possible issues at runtime. So a lot of the problems and friction you feel is your internal developers who are your friends anyway, probably, and the rest of the world have a pleasant experience because of it. So that's it. The value I see. And I wish more people would get on TypeScript. Now, in that spirit, what I feel like doing is helping JavaScript developers who feel that friction go, you know what, start with TypeScript. Use no strictness. And just eddies everywhere and then fill them in cumulatively. Uh Huh. This is like with Russ doing the U64 thing. What do you think of such an, is that a good idea? Like, It's tricky and there's no right answer. There's no wrong answer. I know I'm putting you in a hard place, but it, [00:28:00] there has to be some way to onboard people with as little friction as possible. And, how close is this to that? Totally, I think you're right to say that there is some friction. Coming to TypeScript or Rust where there is stronger typing than we might be used to. But I think the benefit that you're articulating very well is that, yeah, you might have a little more work in the front. Part, I don't want to say front end, you might have a little more work on the front side, whatever that is, and that might, that'll set you up better for success later. So it's that balance, right? But I think TypeScript really is filling. A need that's been there for a long time where we have these bloated JavaScript applications or these bug ridden JavaScript applications and TypeScript can help us to [00:29:00] Think through some of these choices we're making just like Rust can so I Find, I struggle with it too as a teacher from teaching very basic JavaScript to folks, how quickly to introduce them to TypeScript. Is it right away? Is it when is it? That becomes a tricky thing, but I think ultimately the thought process that goes into creating an application, you don't want to, you don't want to take too many shortcuts with. So I struggle with this. This keeps me up late at night. So. Yeah, I could talk about that forever. I'm glad I'm not the only one. I want to invite listeners. Tweet at or post on X, I should say at pod rocket pod, I think, and tell us your thoughts and answers because that's, it keeps me up at night as well. Awesome. Eve, we're about to wrap up. But before we do, I want to get your, shout outs, at least one, one shout out for something, somewhere in the Rust space that is making a [00:30:00] real difference. To give you some time to think about that. I'm happy to share mine while you think. I've been, as I mentioned earlier, I've been working with some friends at a very small startup called Crab Nebula. It has nothing to do with space, but Crab apparently is like Rust with Ferris and so on. And they, I had the privilege of attending a 90 minute workshop on Rust by this dude named Jonas who works there. And in terms of teaching, I've never... I've never in my life seen someone so well versed, able to break down concepts into I asked the silliest JavaScript person questions on earth. And he was patient, he was kind, and it was the best spent 90 minutes of my entire week. So, shout out Crab Nebula and the work they do in and around the Rust ecosystem has really, I've experienced that firsthand. I'm really thankful for it. Yours. That's amazing. I think just another shout out for Rust Playground. Definitely check that out. But resources to look at Rust Adventure by Chris Biscardi is a great one. He has a lot of free resources on his site as [00:31:00] well as some videos and just. a treasure trove of great stuff there. I'm going to say two because I don't follow directions. The Rust for JavaScript Developers by Sid Chatterjee is a great one as well. Particularly for those of us coming from a JavaScript background, there's a lot of great one to one parallels of language features in both that make the Bridge to Rust from JavaScript, easier to cross. So I recommend both of those highly. That's awesome. I did say at least one, so you didn't break any rules. Okay, cool. And also, you know what you did too, I'm going to do too, I, BUN has seen a lot of hype and somewhat controversy, but I think one thing that some friends of mine certainly missed, and I think maybe more people did, was the fact that you can just import Rust modules into BUN files, just like straight up import them from cargo from cargo, from crates, and they just work, they're just [00:32:00] compiled to, I think, WebAssembly or something on the fly, and what? That's mind blowing. Isn't it? That's such a good you can just like interrupt with Rust from JavaScript, it's nuts. We, last question, and then I'll let you go. I'm really thankful, by the way, for your time and just the dialogue has been fantastic for me personally. If somebody wanted to get started with Rust and now we're talking off playground, etc. I understand that there's a tool called Cargo that they can use to bootstrap projects, install dependencies, like. The JavaScript world, etc. What is Cargo? How do you use it? What's its role? And is it, how close is it to NPM or PMPM in like publishing, version management, etc. pretty close. I would say Cargo is, yeah, coming from a JavaScript background. It's super close to NPM. It allows you to manage your dependencies and update versions, all of those things. And also to. Explore the different packages that are available to us in Rust, so [00:33:00] we think about npm as this thing that just allows us to manage our projects, but really the library part of it, the lookup of projects, part of it is pretty cool too. So cargo does the same. So yeah, using cargo for your first. Maybe you're to steal an app from you, your questions app or something like that. Might be a good way to get started, build a little CLI and start to explore all of those types and data structures that you can get your hands on with all of these different cargo projects. Awesome. Awesome. Awesome. I just thought back to one thing you said, which you said in, in Rust numbers are not numbers, right? This reminded me of JavaScript, where if you do type of nan, it is a number. So, so type of not number is a number. Gosh we've come full circle here. Listen, Eve, it's... It's been such a pleasure having you on the podcast and [00:34:00] kind of geeking out about the details about non numbers, about U64s, about NEs and the closeness between TypeScript and Rust. And really, thank you. It's I don't take it lightly that you'd make so much time to, to come hang out and geek out. So, from everyone at the podcast and myself, thank you so much. Thank you so much. It was my pleasure.