The unlikely friendship between Rust and React with Sara Vieira === [00:00:00] Hi there, and welcome to PodRocket, a web development podcast brought to you by LogRocket. LogRocket helps software teams improve user experience with session replay, error tracking, and product analytics. Try it for free at logrocket. com today. My name is Paul, and joined with us is Sarah Vidarida. She is a developer over at axo. dev, and we're going to be talking about the unlikely friendship between React and Rust. Welcome to the podcast, Sarah, Ah, thank you so much for having me, Paul. we're going to be getting into, the oxidization. So to call it of some of the tech stack that's happening, rust has been a player in the space and it's, you know, been increasing in usage ever since. And I'm sure some people listening have heard of towery, which is going to be one of the topics of discussions today. And just like how we can start to build more performance. better maintained and highly scalable cross platform applications. So before we like hop into [00:01:00] what is towering and all this, what inspired you, Sarah, to hop into the next stage of saying, I'm not going to do just JavaScript, TypeScript, I'm gonna, I'm gonna mess around with rust. Like what caused that? Fair, you know what, fair point. I don't even like TypeScript that much. So I just went from loving JavaScript to like jumping into Rust. So I wanted to learn some sort of backend language. And I think what drew me to Rust. Was that I wanted to try something that had very strong typing. Like I wanted to understand, do I not like types or do I just not like TypeScript? Because these are two completely different things. So I decided that I wanted to try Rust mostly because of that. And because the community seemed nice, which like I think is often overlooked in languages and like when you want to start with a library or something like the community in Rust is nice. Like people seem very nice to people who are trying to learn. And it seems to be somewhere where there is a. Like, a very substantial number of women. So I was like, okay, I'm gonna try and learn some Rust. And then I [00:02:00] gave up, but then I applied to Axel, which also does Rust. So I was like, okay, now I have an excuse to learn Rust. It's like moving to a country as an excuse to learn the language. Which sounds like you could've just learned a language, but, in your head, moving to that country was easier. Speaking of that, I lived in Germany for five years and learned no German. That was a very roundabout way of saying I joined Axo and also because the community sounded nice and I wanted to learn something that had very strong typing. a good community is something that like you pointed out is often overlooked and something that can be hard to find in the intense discourse in the JavaScript ecosystem. You can, you get a lot of interesting opinions that crop up There's so many people in the JavaScript ecosystem. I think there's also that like, it's hard to mitigate between so many people. Like the Rust one is smaller, doesn't mean it doesn't have bad apples. Everywhere has bad apples, but like, it's just feels chiller. So towery, we're going to be talking about towery today if people hear rust and they hear react, I think a lot of people might immediately jump to [00:03:00] like web assembly or some sort of way to have rust power, or a typical web application. Specifically, we're talking about towery today, though. So for folks who aren't Privy to what Tauri does for us. What is Tauri and what does it sort of replace, so Tari is a way to build native apps. So think about electron, but the backend instead of like backend isn't like the main process, as it's called an electron is not JavaScript it's rust, which makes it. Much faster to have intensive CPU stuff or any sort of CPU stuff. It also gives you access to way more stuff, way easier, which is nice. So what's some of the stuff that it gives you access to? Like it gives you access to everything, but I think also Electron, but for example, if you want to have access to what, like how much your RAM is being used, it's way easier in And towering or like the example that I did for my talk was like how big your discs are and like have an overview of like, how big, like how much stuff you have in your discs it's not [00:04:00] hard because I think one thing that a lot of people also don't. No, because they don't do Rust, is that Rust is a very big ecosystem when it comes to packages it works like NPM. So it's a lot of this stuff, people have already needed it before for something else. And also, since it's a low level language, it has access to everything in your computer without you having to like, exec anything. So It's much easier to do any sort of stuff that actually requires access to the hardware, like to know which hardware. Like I ran one package and it told me everything about my computer. Like how much RAM I was using, like what programs were open and stuff like that. Then it's about getting this data and showing it basically. What sort of things does Tauri provide that Electron maybe doesn't provide in the same flavor or with the same level of refinement? And because when I think of Rust, I think of speed, memory management, and all this sort of stuff. So I'm curious what of those qualities boil down into the Tau'ri runtime? All of them in general [00:05:00] boil down into the Atari runtime. But I think there's also the fact to know that a lot of times what's slowing an electron app is actually the front end that can still be shut, right? Like you can't fix people's JavaScript for them. But I think a lot of the stuff is like, if. A lot of the stuff about Rust, about like how fast it is about reading files and doing stuff like that definitely boils down to Electron, like it triples down to Electron and it makes a lot of this stuff way faster. It also does make, one thing that it does, that it's not something that I really care about, but I've seen a lot of people complain about when it comes to Electron, is that the file size of the installer is smaller. Mostly because it doesn't have to pack in the entirety of V8 and Chrome, almost. Uh, It uses a subset of Firefox, and it doesn't actually need a lot of the stuff that Electron needs. So that makes the installed size smaller, which is nice. Like it's not something that usually bothers me very much. Cause I'm like, I just have to download it once, but it is nice to see that something like we can make them smaller. There is also like one part that I truly enjoy about. [00:06:00] Their docs is that there is a dockage exactly to copy and paste a github action to build for every platform And god bless who wrote that whoever wrote that is a hero You can just paste that github action and you will build your app for Linux Mac and Windows so my follow up question then is if somebody. Was writing an electron and they were interested in Towery and they go, Oh my gosh, it's rust. I have to learn. I have to go build an app and rust. Do you need to know a lot of rust to take your existing front end code and just run it? in a Tau'ri based environment. I mean, I think that depends a lot on what you are doing in general. I think you need to understand some stuff. Okay. I think the thing about Rust is that it's the opposite of JavaScript. The thing about Rust is that it's hard to pick up, but then it's fine. JavaScript is really easy to pick up, but then you're going to find some like really nasty errors. So you have to learn some Rust. Like you don't have to learn a lot of Rust [00:07:00] but you have to learn. All the type system works and I'll borrow the borrow checker works, which basically means like you can't use the same variable twice and stuff like that. It's not something that I can explain, honestly, but it's so there is a lot of stuff that you do need to learn and that you need to understand that There is no escape hatch. You have to type it out. Like you don't, you can't just write any and continue with your life. So I do think there is a high entrance. I do think that if you're trying to do something that really requires like shell access, for example, or requires reading a lot of files or doing a lot of the stuff. I think this learning curve is worth it, but there is a learning, like you have to learn a ton. But the good thing is if your code compiles, it most likely works. Like, I think I had that happen once when it didn't work. And it turns out there was a bug in the library. So Oh, it's not even your fault. yeah, no, it's, that's the thing. Like if your code compiles, it works. Like you can get frustrating until you realize that because when I used to that, if we get a bunch of TypeScript errors, you will still [00:08:00] compile. The code will still compile. You can just type any on it and no one cares. So it's not the same in, in that sense. buT it's not impossible or anything, like it's just, it takes some time to not get frustrated and then you're gonna be okay. But you do have to learn some Rust, I'm sorry. I feel like a lot of people have heard the phrase if your code compiles, it'll work. And people have also heard, Rust, you have to type it out. And maybe I would love to hear an example from you, Sarah, about like when that wall hit you and you were like, whoa, wait how do I type that out? Like what was that real life example I think I have one example that I have is from one of the first projects I built with Rust, which was when I joined Axel, in which they were like, okay since you have never used you've only used Rust Very little let's make a CLI and I was like, okay, let me fetch an API. And then I realized that when you fetch an API, you have to type out the entire API that you're getting back of for Rust to be like, okay I understand to a point where I was like I think it's easier for me to [00:09:00] create a new endpoint in my API that just returns what I know So I did There is a bunch of stuff like that. So it's very important that you know, if you want to use some sort of API, you will have to type out the entire API, but if you go on I think it's transform, if you type transform, I mean, it used to be that now that I say, but I have no idea where it is now they have a Jason to like. Struct compiler, which is beautiful, where you just, you input some JSON and they give you the structs and it's magical. there's stuff like a string is not just one. There are several types of strings and stuff like that. But I think the first time where I was like, Oh damn, I have to like, I have to do this. It was like when I did it one of the first times and I was like, I have to, my entire API. All of it, just to return one value. Why? And I would assume that makes it even better when you find a library that does exactly calls the API or is a wrapper because they do all that work for you and they maintain it because APIs change.[00:10:00] Yeah, that's also another problem, right? And sometimes if the API changes, it might break your app. It may break in JavaScript, obviously, but it more likely will break in Rust. so it's nice when people have like wrapper APIs, like it's nice in JavaScript. It's so much nicer in Rust. Yeah. Not to make the learning curve seem like you shouldn't. Do it like Sarah saying like you should absolutely do it if it's the right tool for you But it's just it's interesting to hear from your perspective It's yeah, you do have to type it all out in that reaction of like, oh my gosh. Is that even real? Yeah It is you're not alone. It's okay. You can figure it out I like your solution of like I'm just gonna make my own end point like why not if you can do it Why not it just makes it easier move on, you know What about testing and debugging? I'd love to hear about because this is a new framework. It's new paradigm. Right before we talk about testing and debugging, though, I just want to remind our listeners that this podcast is brought to you by log rocket. So for your app that you're building, if you're trying to find errors, and spend less time debugging and more time writing a good app, log rocket. You can use [00:11:00] LogRocket to surface trends and other issues that you might not have noticed. There's heat maps, full session replay, and all other sorts of data that you can get into your console. So head over to logrocket. com today and check it out for free. So Saira, turning back to Tauri and testing and debugging, how do you begin with that? Do you have to make your own test framework? Is there one out of the box that's typically used? Yeah, no, Rust comes with a testing framework out of the box. So you just, you create like something that just is like a hashtag something test, and then you can write your own test for the code that is above it. So technically I think. The most common thing for people is to write the test in the same file they write the code. I don't really like that because it makes files very big, but that's fine. But the thing is there is already a testing framework. When it comes to debugging, it is actually not the easiest. So you have to console log, which is basically a print line. You can print or you can print line, but you're never going to use print without print line, because [00:12:00] then everything just becomes a smush. But some things have to be printed in a specific format, while some things can just be printed as text. And there's even the problem of Some things cannot be printed because they don't possess they're not debuggable for some reason. This has happened to me in some libraries that I import which did not set the the um, I forgot the name of the thing, but you can set things to be debuggable, to be serializable and un serializable and stuff like that. If you don't set debuggable, then you can't print it out. So I would say the experience of doing this kind of stuff in Rust isn't Bad, but when you start using some libraries, you may come into issues when it comes to that as in like console logging sometimes can be weird. Shouldn't be hard, but it is sometimes, testing is fine. Testing is actually really good when it comes to Rust is really good at testing and the rest is just a bunch of react testing, which is the exact same thing I've never really tried to do test as in like you open up the app [00:13:00] and actually start doing the testing. I'm sure it's possible. And yeah, but that's more like screenshot testing. So that's, that would be the same. That would not be specific to Rust. Comes to Rust, they have their own testing thing, which is actually quite good. You describe and it's equal to something and , it has everything you need, which is actually so peaceful compared to like to set up a JavaScript one. So debugging Has a bit of a learning curve, but testing out of the box. Awesome. Awesome. What were some of the real life Debugging examples that you can give us like you said the print versus print line thing just a little knit right there You know you want to use print line Oh yeah, you definitely want to use And some libraries, maybe they don't play nice because you have to set debugging what was that piece you have to set a debugging flag. println. Yeah, like you have to allow, what is the word? You try to open anything that I have that is in Rust. So you have to derive something and derive is something that comes from Serde [00:14:00] and Serde is like a serialize and deserialize library. And also you'll have to set it that thing if you want. Okay. So very important thing that I forgot to mention is that anything. Which is, I think, one of the things that's harder for people to pick up when they start Tauri. It's everything you pass from Tauri to JavaScript has to be serializable. And that's not the end of the world because you also have to pass JSON. In general, between these two things, and it has to be serializable. But the thing is, it has to be serializable using something called SerDe, which is a library that does a lot of this work. So if you use a library, and that library does not use SerDe to serialize their types, then you have to do it yourself. So You can't just pass things through because they may not be serializable. And when you want something to be serializable, you'll have to set it as serialize, deserialize if you want it and debug. [00:15:00] So if you don't set it as debug, you cannot print out because you did not pass a debug flag. I don't understand why that's a thing. I don't think that makes sense. I think like by default, everything should be debuggable. Mm hmm. I think this is a really great topic like the serialization and the necessity to have that quality of the data that you're passing to and fro. Something that you pointed out Sarah that I'd love to double click on is the fact that some libraries. Might not be serializable out of the box for Their structs or the data that they're passing to and fro the structs and the data in general. Yeah, yeah, yeah, yeah, it's So if you were to like pull a crate down, would you have to write that serializable like wrapper? Or superclass. how would you frame that? . So basically you have to create your own struct. So let's say you create a struct called disk, which has a name, which is a string, which has available space, which is an integer or whatever it is. So basically then you have to get the types from this library You have to get the data from this library and basically make sure that it matches [00:16:00] that type So that struct you created to then return the struct Instead of just returning the like whatever the library gives you'll have to make sure these two things match so like for example, one example that I have here is that like The disc, that name that they returned me an OS string, which is not exactly a string. So then you have to turn it into a string and then you have to unwrap it, which basically means do the thing or throw an error if it doesn't work. And then you have to do two string again. So it's like a bunch of stuff may come like this, which is like an OSS string is not serializable while a string is, so you cannot return an OSS string. You have to like take it out of this container, throw, if there's an issue and then rewrap it as a string. Yeah, so other stuff is like something may return a path and you don't want to return a path, you have to return like a path buffer or something like that. And a lot, all of this stuff has to be typed out and have to see which things can be returned and then you have to transform it into that. Basically. But at the end of the day, effectively, [00:17:00] it's a struct wrapper with Yeah, effectively, it's just a structured wrapper. Awesome. Awesome. So in terms of your projects right now, Sarah, what do you have your eyes feasted on? Right now for expanding your own, like knowledge with the rust ecosystem and its collaboration with JavaScript and react. And is there like a project in particular, like you mentioned the disk space project that you did in your talk, just to demo it, that you've been working on maybe currently that you're super into. I was working on for a while on a project So I'm really heavy into retro gaming So I have a bunch of like handhelds and all of them have their own SD card which have their own ROMs Which I have no idea what's in them at this point. So I wanted to make some project I would like actually read it My files in them and be like, okay, so this matches this game. I got all of these games legally, obviously. And like this matches this game or something like that. I wanted to do something like that. I always end up like, oh, this is going to take [00:18:00] me a while, but it's something that I really want to pick up because it's something that I would like for myself in general. So yeah, that, that's the thing that I'm like, I got my eyes on and I'm like, I'm going to do this one day. I'm going to make this, I'm going to be useful to the retro gaming community And Towery is good because I'm just like reaching to the beginning of our conversation. You said for really low level primitives and like wanting to read. The OS wanting to, it's perfect for that yeah. Also because one of the APIs that is used for getting data for certain ROMs requires the MD5 hash or CH1, CHA1 hash of the file. So that's something that takes forever to do in JavaScript, like if you have a 50 megabyte file, for example, and that's something that's way faster to do in Rust, get the hash of a file. So those are the kinds of things that are way faster in Java and in Rust or like reading an entire file directory. Like I'm not gonna get a bunch of speed improvements for doing fetch calls or stuff like that But getting a bunch of speed improvements [00:19:00] for doing Like file stuff and hash stuff because what I want to do is like hash every single File that you get so that like you don't have to fetch the same thing twice and stuff like that So that's something where Rust can really help. terms of adoption, when it comes to being easy to use and easy to make a product, that's usually at the forefront of a lot of teams as minds and, you know, That's not Rust. right, So that's why I'm curious, if what tower is bringing to the table here is in any way going to disrupt electron and in any way, change the approach in general, let's say over the next decade. Of how this is done. I don't wanna say this just outright, but I don't think it's gonna remove Electron from the top, but I do think many people will use it. So let's say you have a company that wants to make A desktop app, if you have to hire people either way, why not make it entirely like it's going to be faster. It's going to be better to maintain and stuff like that. So I think, and there's also a big [00:20:00] overlap of there's a bigger and bigger overlap of people who know JavaScript and Rust. , so I went to Eurorust this year, and it was in Brussels, and for some reason, React Brussels was at the exact same day as Eurorust. Because the guy of React Brussels didn't think there was an overlap, and then there was a bunch of people at Eurorust that was like, I wish I could have gone to React and I was also like, yeah, why the hell did they make it in the same day? Same day, because there is quite a, it's not like huge, but there's like a bigger and bigger overlap of people who know both things. So I think it's about playing to your strengths. I think if you have a company and, or, you know, rust, I think it's a great thing to pick up. I think that if you're an indie dev who just knows JavaScript, then Electron still makes sense for you. And I think that's a lot of the cases. So I don't think that it will remove Electron from the top, but I think we'll give it a contestant. And I think in general, competition is good. I mean, Let's talk again in five years and see, maybe I'm wrong and then Electron will die, but I don't think so. I [00:21:00] think Electron is still a very good tool, that's the thing. like they use two different aspects in the backend, which makes it two different communities that will attack it. I guess Last community related to question, what do you hope the react community can learn by osmosis over the next five years from these new? Types of paradigms like towery bringing rust into the picture I think a lot of that the React community can learn from the Rust community is . I think there's way less gatekeeping in the Rust community than there is in the React and JavaScript community, which is weird because Rust is harder to learn. So I think a lot of the JavaScript community can learn from the Rust community is this openness to first of all, new ideas to second of all, people in general I think the Rust community ends up being a way more welcoming space in, for any minorities in general. And I think that's something that like, all. Places can learn to be fair. Yeah, I think that's the main thing. It's like they're just nice Like they don't focus on [00:22:00] like naming and stuff and I like that. I just want to make the thing, you know I like that. There's always bad apples everywhere. But in general like I think it's a Nicer experience, mostly if you're from an underrepresented group in general, the Rust community. so Sara if people wanted to keep up to date with your adventures in rust or outside of rust Of course, do you have a Twitter or another social where you post? Your thoughts. Yeah, so I still use Twitter. I'm waiting for threads. I tried to use all of Mastodon, and I could not. I just cannot. I don't know why. I try, I promise. I'm still on Twitter with NikitaFTW with two Ks. And Yeah, I think that's the best way to keep like knowing what I'm about to do next. I'm also been refurbishing old game boys. So that's about a lot of what you're going to see there and me complaining about airports. Yeah. Game Boy and Rust Knowledge follow Sarah on Twitter to keep up to date with Game Boys. [00:23:00] Rust and I guess airports too. Sarah, thank you for your time. It was great having you on to learn about the unlikely friendship between Rust and React. Oh, thank you so much for having me and yeah. Have a great week. Bye.