647

July 31st, 2023 × #javascript#rust#nodejs

Rust for JavaScript Developers - Node vs Rust Concepts

Compares JavaScript and Rust at a high level, including cargo, documentation, async/await, error handling, syntax differences, and more.

or
Topic 0 00:00

Transcript

Scott Tolinski

Welcome to Syntax.

Scott Tolinski

Today, I'm feeling a bit rusty. That's right. We're talking about Rust or JavaScript developers. We're gonna be comparing some of the stuff that you might have used in the JavaScript ecosystem to the things that exist in the Rust ecosystem.

Scott Tolinski

It. And we're gonna be doing so at a very basic, basic, basic level. So there's no expectation that you've ever done anything in Rust Or even we'll do anything in Rust, but maybe it's a good idea to learn some of just exactly how these systems can be a little bit Different. My name is Scott Talinski. I'm a developer from Denver. And with me, as always, is Wes, the cottage boss.

Scott Tolinski

Yes. Here I am. Did you see my new beer bottle that I got? No. But I see the Snow Goose Lane sign and I love that. But that is a big papsed

Wes Bos

Blue ribbon bottle. How is it glass? Yeah. It's got beer. So we were just, like, driving down the road and Caitlin's like, oh, they turn around. There was, like, a little yard sale. Like, not like a Saturday morning yard sale, but, like, some guy has stuff for sale it constantly. Not like a Saturday morning, Yarns. No. Just like a somebody in your house on a heavy traffic street.

Wes Bos

It. And she's like, there's a huge paps blue ribbon bottle, and it's probably probably 3 feet tall, Full glass. And the guy said it has been sitting in my in my garage for, like, 40 years.

Wes Bos

And he's, like, $10. I was, like, sold sold sold sold because I'm trying to figure out my camera angles in this office, and It's pointed right at the crack of the corner. So I was like, I need something to go in the corner, but I'll say the bottle is It's not working, but I'm going to put it somewhere else. I mean, you could build a little stand for it. Yeah. I think so. It's got to look a little bit more More natural than that. Like, I'm trying to do you know who red green is? Like a wooden crate. Yeah, that might work. Yeah. Like a wooden.

Wes Bos

I'm more thinking, like, lean it against a shovel or something like that. Yeah.

Topic 1 02:33

Red Green was a hilarious Canadian TV show about duct taping everything together

Wes Bos

Do you know red green?

Scott Tolinski

Did you grow up with Red Green? You know what? We I don't know if that's something that we had, but I've heard the name. I I only have Probably heard the name through association with other things. But, no, I don't really know much about Red Green. So I know Tom Green. When when we were growing up, we had the show on Canadian television called Red Green. And

Wes Bos

it was like, how do I describe who Red Green is? If you Google Red Green Possum Lodge, you'll see what I'm talking about. So It was a show where they did, like, skits, and he would do, like, the most hilarious, like, I guess kinda like redneck y stuff. Mhmm. But it was, like, very wholesome, very Canadian, and he would do things like Duct tape everything together. That was the way he and his his tagline is if if women don't find you handsome, they should at least find you handy.

Wes Bos

And I freaking loved that show growing up. I thought it was the most hilarious thing in the world. And he their set, The set that they had was called Possum Lodge. If you Google Possum Lodge, red, green, you'll see what I'm talking about. And that's kind of my end goal with this office is just us. All kinds of random deer antlers and geese and fishing equipment and stuffed chickens and Yeah.

Wes Bos

Fish. And it. I got a pair of deer antlers and all kinds

Scott Tolinski

of interesting stuff. Gas cans. Wow. We we were on the hunt for a taxidermied animal it. Our our office went at one point at an office I worked at, and there is some wild stuff available. It's you're not allowed to buy it in In Canada. And I I once

Wes Bos

saw a massive pike on marketplace, And it was like 5 foot long pike, like jumping out of the water mounted. And someone was selling it for like $30.

Wes Bos

And I was like, I'll be right there because it. Because you're not you're not supposed to be able to sell this kind of stuff because it's otherwise, people start killing animals when they shouldn't be.

Wes Bos

So I ran and then I knocked on the lady's door and she's like, I'm sorry. I've had offers for instead of $30, I've had offers for 500 from, like, movie sets and stuff like that, Trying to buy it because I don't I don't know how you legally buy this type of stuff, but I wonder if you could permanently rent it. Yeah. So she She's like, sorry, I'm taking the money. I don't care that you just drove here.

Wes Bos

But we did find, like, 2 huge lake trouts once at a thrift store.

Wes Bos

And often the thrift stores don't know the rules and whatnot, so I did get to buy a nicely mounted set of trout. I wanna,

Scott Tolinski

thrift store finds, Wes, Or like consignment fines. I know this is getting away off topic here. Let's let's get it.

Topic 2 05:13

Found a $700 snare drum for $100 at a pawn shop in Montana

Scott Tolinski

One time I found Like, a signature series high end wooden rimmed Yamaha snare drum for, like, $100 at a Pawn shop in Bozeman, Montana.

Scott Tolinski

And I was there with my family going snowboarding. And when I saw this thing, it was like, this is like A $700 snare drum for nothing. These people do not know what they have, and I got the fanciest snare drum. I had to call the I I ended up it. Calling because we left, and I was like, man, I wish I would have bought that snare drum. I couldn't fit in my suitcase.

Scott Tolinski

So I ended up just calling every pawn shop in Bozeman And found it, and they shipped it to us. It was like I ended up paying, like, $300 or something for it, but it was still a, you know, nominal price compared to Actual value of that snare drum, and I still have it. It's my favorite my favorite snare drum. That's amazing. I find I find, like, pawn shops

Wes Bos

are never a good deal. Every time I go into 1, I'm like, I can get this cheaper at the store.

Wes Bos

Like, why is this this so much? So I think they've they A lot of them know what they have. That's amazing that they didn't know

Scott Tolinski

that they had a $700 snare drum. Yeah. It's a beauty. Alright. Let's get into instead of rusty, the rusty equipment in the shed. Let's get into some rusty code and and talk about Rust and JavaScript.

Scott Tolinski

So I felt like what we could do is probably get us. A few different episodes about this going into different aspects of Rust versus JavaScript. So if you're starting to get into Rust and you see some terminology around or you want to Try it. You at least kind of know what's what and where you're at.

Scott Tolinski

So, to start, I think we should maybe talk a little bit about Things that are in Rust first JavaScript for instance. In Node world, you have NPM as your package manager. NPM is its own thing.

Scott Tolinski

You also have PNPM or Yarn, but NPM is the package manager of Node. Essentially, comes when you install Node.

Scott Tolinski

And likewise with Rust, you have Cargo.

Scott Tolinski

Cargo is the package manager for Rust, and you see Cargo very, very frequently in the Rust world. Because unlike in the JavaScript world, Cargo does a massive amount for you beyond just fetching your dependencies.

Scott Tolinski

So in JavaScript world for, let's say, like testing, you have v test. You have jest. You have mocha. You have You have all these different, things that work together to do testing.

Scott Tolinski

In Rust world, you have cargo. Cargo is the test runner and it comes as a part of the package manager.

Scott Tolinski

And you're going to see this same Pattern very frequently. Because as I tell you this, like, what else can Cargo do? Well, Cargo, can do testing. It can build your documentation.

Scott Tolinski

So if you do cargo doc, it can give you documentation, based on how you're writing your code, it can publish libraries. So if you're writing a library in Rust, you would use Cargo to publish that library.

Scott Tolinski

So cargo runs your code as well. Cargo run is the equivalent of, like, NPM start and running a script even though that script just runs Usually like Node or Vite or whatever. Cargo run is actually how you run your projects.

Scott Tolinski

There's also the main package File in Rust is cargo.toml, t o m l, which is what what does tamil stand for? Tom's Tom's own markup.

Scott Tolinski

Tom's obvious minimal language, and that is Tom Preston Warner, a former guest on Syntax who created TOML.

Scott Tolinski

So, TOML is one of those things that's kind of YAML esque, but, it's more obvious, I suppose. I we should maybe do a dive at some time in the differences between TOML and YAML. But, yeah, TOML. Cargo. TOML is where you put all your dependencies. And not only that, you can, like, tell it a specific features that you need to use to, like, elaborate upon certain packages that, you know, you might need to tell it, hey. Use this feature or this feature from This this specific package to use more things from this. Oh, and one last1, cargo build builds your project. It's like a in a in a way to that you can ship the project. And when it's built and shipped, is that what a crate is or what's a crate in Rust's world? A crate is a package.

Scott Tolinski

So if you were installing a package like Express in JavaScript.

Scott Tolinski

A crate is the package that you publish. So when you do cargo publish, it takes your code and puts it onto something called crates Dot I o, which is the package registry inside of Rust. So like NPM. Beautiful. Cool. So that is Cargo. Cargo does just about Everything as you will see. It it it can publish your docs. It can publish your library. It can Yeah. Run your tests. It can get your fetch your packages, publish your packages, build, all that That seems to be like everybody uses

Wes Bos

cargo because you look at JavaScript landscape, and obviously, we have NPM, but then other there's Other package managers that people we have, PNPM and Yarn. And then you look at the Python landscape, and there's All kinds of different things in the Python landscape.

Wes Bos

And sometimes it's frustrating, like, can't we just settle on 1? Isn't is there alternative things in the Rust community, or do they just use cargo

Topic 3 10:27

Rust community seems to have standardized on using Cargo, unlike Python/JS communities

Scott Tolinski

for everything? Everybody uses it. I'm not enough of a Rust head to know if there is such thing as an alternative, but I I I mean, I I don't think so. I think that it is you know, there there's recently been, like, a an entire fork of Rust called the it. Which is an entirely different bundle of drama and stuff like that to get into. But Really? Yeah. But so I I don't know. Because Cargo is so tightly integrated into everything. I can't imagine there is something else, but I don't look, again, I don't I'm not enough of, you know, deep into the Rust world. I'm more of a hobbyist Rust developer.

Scott Tolinski

So next step is let's talk about, like, documentation.

Scott Tolinski

You can Generate documentation from your code. And that's something if you ever go on to, crates.

Scott Tolinski

Io, You're going to see that all of the packages, like, let's say we go to any package on crates. Io.

Scott Tolinski

You'll be able to see they all have c s Oh, read me. And they all end up having pretty good documentation, for for most packages because it's really easy to generate Documentation directly from your your code itself, and that actually comes in handy. You can write Comments and, and have it be parsed as markdown directly in your code. There's some neat things there. But for the most part, you know, one thing that I found to be interesting with Rust is that the docs that get published in fact, let me I'm I'm trying to find a good one because I was just On a a big project that I've been working on. So you can publish your docs really easily on what's called docs c s dot r s using, Cargo to publish your docs. Right? And with docs dot r s, it basically is Let me I'll post this 1 in the show notes. This is a specific package, just a random page from a random projects package.

Scott Tolinski

And This is kind of what all the documentation looks like on here, and it's kind of no fluff. It's not a lot of the things in the Rust world And this level on the web aren't necessarily what I would describe as, like, pretty or well designed.

Scott Tolinski

That's just my own personal preference, but This is the type of page if you ever link to or if you're watching the show and you wanna click through through some show notes, it's very, you know, Generate like, when we had JSDoc generated docs, it's very much that style.

Scott Tolinski

It tells you the functions.

Scott Tolinski

It links to their source. It allows you to, see all of the methods and structs and whatever that's available anywhere in here. Allows you to see all that stuff. It allows you to even have a quick copy to be able to use it in your code like a copy paste thing. So it's very nice and functional.

Scott Tolinski

But at, Like for a a little you know, somebody who's getting into Rust from JavaScript, you might hit a page for a documentation for a library, and it might Very much look overwhelming for you pretty quickly because it is very code heavy. But I can guarantee that if you Spend some time in here and, like, really learn how to read this documentation on docs.rs.

Scott Tolinski

You'll find that over time, you'll not only get better at reading Rust code, learning Rust itself, but also even it'll Oh, pay dividends in getting into JavaScript documentation because it is much more of a technical style documentation in more of a hand holdy style documentation.

Topic 4 14:07

Rust documentation is very code-heavy and functional, less hand-holdy than JS

Scott Tolinski

But it's it's all fully documented, all your methods and everything. And you're saying those are all generated from the Rust code Right? Because because Rust itself is fully typed? Correct. Yeah. Rust is fully typed, and we'll talk a little bit about what that that looks like to do.

Wes Bos

How do you do examples and descriptions and all of the stuff that you would do with JSDoc in Rustoc? Is there like a syntax for comments Or what does that look like? So I've linked to a post from,

Scott Tolinski

practice dot r s or Rust by practice. And this shows you just kind of a general idea of the comments that you could have for docs.

Scott Tolinski

And it does feel very JS docs like, But when you're writing comments into your code, it it is it can take these comments and generate the, Docs based on different little helpers, in your

Wes Bos

in your code. It's it's just like Markdown in comments. It seems a lot less rigid than JSTOC. You simply just put a bunch of single line comments, And then you do pound panic, pound example, pound arguments, And you can just Triple back ticks for code examples and stuff. Oh, that's nice. That's way better than like, JSoc is good, but you have to know the syntax, And this seems a lot more loose.

Scott Tolinski

So the reason why this is so good is because it is statically typed. With JS docs, you have to, Like, type your code to describe your code, essentially, the parameters and arguments. Yeah. You don't have to do that here Because it's statically typed by default. Right? And so what ends up happening is your docs and your comments end up kind of, like, morphing into docs And comments depending on how you like to write your code. Yeah. And that not only, like, helps read code in Rust world, but it also helps The documentation end up being really nice because it's all, you know, comparatively together.

Scott Tolinski

And likewise, so, like, we kinda got into this with typing. In in JavaScript, you can get, like, TypeScript for static typing. But in in Rust world, it is very TypeScript like static typing.

Scott Tolinski

You do have things like generics, and they're the same syntax as you do in TypeScript.

Scott Tolinski

And a lot of times the the type syntax for defining types on things feels more like TypeScript than any other type system that I've used personally, and that made me a better TypeScript developer. But it also made me a better Rust developer knowing that I, you know, could at least Predict how things might work knowing that it is TypeScript like in how you define your types.

Scott Tolinski

Let's talk about memory safety.

Scott Tolinski

This is one that we could spend a whole episode on, but where JavaScript has garbage collection, Rust is, is built in memory safety without garbage collection. And what that means, we would wanna be getting way deeper into the entire idea of Memory usage within Rust. So I'm not gonna touch that beyond just saying there's no garbage collector in Rust like there is in JavaScript, But it is, memory safe.

Scott Tolinski

Next is, concurrency. JavaScript is single threaded, and Rust has support for multi threading. So Not anything that we're typically worrying about as web developers here. But if you're the type of person, who is into higher level languages, getting into the concept of Threads is a great way to, take more control over your application. Again, as as web developers, it's, like, very, very rare that we're thinking about Right. Right? What about, like, promises, async await in Rust? What does that look like? I just did a quick Google. That's called the future. Is that true? Yeah. But there is a sync await in Rust.

Scott Tolinski

It's like a I don't know when did a sync await drop in Rust. And it feels very much like JavaScript and that, it's still single threaded.

Wes Bos

So you're not, like, you're not creating a new thread by doing a single await or anything like that. Yeah. That's it's kind of similar to JavaScript in that I think a way to still single threaded. But if you want to go multi threaded, you have to explicitly

Scott Tolinski

it. Do some work to do that. Yeah. And and typically, when you're using async await, it's the exact same, situations in which you would use it in the JavaScript world. Right. You're doing an HTTP request. You're going off and,

Topic 5 18:17

Async/await in Rust is single-threaded like JavaScript, not multi-threaded

Wes Bos

grabbing a file or something. The await syntax And Rust is really interesting. So instead of putting away in front of an asynchronous function, you tack a dot await onto the end of your function call.

Scott Tolinski

Yeah. Yeah. And and it's funny. There's, like, in in Rust world, especially compared to JavaScript. So one thing you'll notice, especially when you get into Rust code at all, Is that there are moments where it can feel very JavaScript like. And then there are moments when you see things like that Or we'll talk a little bit about, like, the double colon syntax or the use syntax or any of that sort of stuff where It is just slight it's it's kind of like bizarro world, TypeScript because some things that you would expect to work do not work. Other things, you know, Work exactly like you'd expect them to, and some of that aspect can get you mixed up. And other times, it can help you push through some learning difficulties.

Scott Tolinski

Another interesting thing in Rust is error handling. There's no, like, try catch, which is honestly one of my least favorite things in JavaScript Anyways, I hate the whole try catch thing.

Scott Tolinski

It well, the way they handle exceptions is via, like, pattern matching, Sometimes, Wes. So you can you can do a call for something and get a result back to it. And that result can either contain, an error or an okay.

Scott Tolinski

Yeah. And then via pattern matching, you're essentially it's almost like a switch statement.

Scott Tolinski

We don't need to get too deep into this syntax because match the match keyword in Rust is kind of like a a bigger topic that I would wanna talk more about. Either way, if you run something like a, a method, you can run that function or a function. You can run that function and then match Or the okay or the error and then handle those accordingly. So it is very much kind of like it it's kind of like, you know, in in, promises in JavaScript you can do a dot then and a dot catch. And it's kind of like that, but not chained as a method to the end. It's sort of like, hey. We have this result, and we're matching this result to either be an okay or an error state. Yeah. It was

Topic 6 20:45

Rust error handling via pattern matching is similar to JavaScript promise handlers

Wes Bos

when I posted some code in, oh, in TypeScript about making the result in the error top level.

Wes Bos

So I wrote, like, a little function that would wrap a promise call, and then it would catch the error or catch The successful result, I'll return both of them in a tuple, meaning that it's an array. First thing is the error. Second thing is the actual result. And then you can just say if there's an error, It's so much better than having to, like, have the scope of try catch. And it's kind of a weird or even a promise dot catch on the end.

Wes Bos

I like that Syntax a lot better of all having it all top level. That's kind of what we used to have in, like, callback world in

Scott Tolinski

No JS land? Mhmm. I, like, kinda brought it back. And when I posted it, everybody's like, this is how Rust does it. Yeah. Yeah. And I and I, like, end up liking it a lot. You know, the The match keyword, again, I I don't wanna get too deep in the match because that's a a can of worms for this episode, especially if we wanna keep it at very basic level.

Scott Tolinski

Mhmm. I I guess it's not a total can of worms, but it it's it's a more complex topic than maybe I wanna get into right now.

Scott Tolinski

I find that to be really nice to use. So much to the point where, like, instead of if statements or even like a switch statement template tag in Svelte World, I I would like them to do something like match.

Scott Tolinski

So we'll we'll talk about that later at a later date. Especially, if if people like this episode, we can do many more of these because There's a lot here to talk about. Mhmm. So, you know, one thing I wanna talk about real quick is some of the syntax stuff. So, you know, I think first and foremost, you could see, like, I mentioned that JavaScript and Rust can feel very similar. And I'll post a, some in the show notes here just a Quick little hello world function. Where in Rust, it's f n hello, parenthesis, brackets, print l n, exclamation point, and then just a string. And that's your equivalent of function hello is console logging hello, world. And if you look at these 2 right next to each other, these very basic functions in Rust And in JavaScript, you can see how similar they can be. Just f n verse function and then print line instead of console log. Other than that, they're effectively the same. Right? And that's that's one of the reasons why I think Rust is a nice language for people who want to get into a more intense world than just straight up JavaScript. Right? You want to be building it. Some more intense stuff than than you could see here very easily just how much your skills may translate in some ways. But Let's get into, like, the import syntax. Okay? This is another one that I actually like way more in Rust because it follows the order in which I want the JavaScript imports to run. So in JavaScript world, let's say you had Express. Your import Express from Express.

Topic 7 23:38

Wish JS imports worked like Rust's use statements, specifying package first

Scott Tolinski

Right? In the Rust world, you use the use command to basically say, hey. This module is gonna become available in this library or in in this file. Right? And then you specify first the package name.

Scott Tolinski

So in the example I have in the show notes, it's STD for the standard library.

Scott Tolinski

Then you use double colon. The double colon specifies that you're you're pulling out, it's it's like, you're pulling out essentially a module, or you're diving into a module. It's it's very similar to how we often use the period inside of JavaScript and TypeScript.

Scott Tolinski

You know, if you're accessing a method or something, there's caveats there. Okay? If you're a Rust head or, you know, somebody very experienced, I'm speaking on a very, a very back level here. K? So you so we have used STD colon colon and then you have a sub module named collections Colon colon hash map is the actual package that we're pulling out of here or the actual methods or functions that we're pulling out of here.

Scott Tolinski

So I wish JavaScript imports work like this where you first specify the module and then specify Drill down into what you want. Right? And what that makes so much sense because every single time you don't get the auto completion that you'd want Because you're having to specify Yeah. The thing you want first from the module. Wherein in Rust world, use Here's from the module.

Scott Tolinski

Here's a sub module, and here's the thing I actually want.

Scott Tolinski

So yeah. Why Why why did they not choose to do it that way in JavaScript? Or even just from the package name,

Wes Bos

import.

Wes Bos

Right. That's what I'm saying. Yeah. The order is what you ordered. Write it backwards, and there's there's snippets that you could you can do to write the package name first. But, Yeah. I mean, it would have made a lot of sense to do the package name first, instead of what we have. But the the auto import tooling obviously makes it better, but

Scott Tolinski

we have a tooling because it's not great. Yeah. So, you know, one thing you'll see in rest is, occasionally, You'll see the at these use statements, they go in the same place as an import statement does right at the top.

Scott Tolinski

Well, I mean, they they sorry. They they mostly do. I wanna say that.

Scott Tolinski

But the one thing you'll often see is occasionally, you'll see use STD colon colon and then it. The module.

Scott Tolinski

Other times you'll see use, colon colon or use use STD colon colon time colon colon and then another module.

Scott Tolinski

And the reason is is that just like in JavaScript, when you sometimes have submodules that are defined with a slash, Right. You could say Svelte forward slash transitions, and that pulls in a transition from the transitions module of Svelte.

Scott Tolinski

This is the exact same concept.

Scott Tolinski

You are sometimes pulling in a module or a method or a function instructor. You're sometimes Pulling in things from submodules.

Scott Tolinski

So if it looks weird to have so many colon colon thing, colon, colon, thing, colon, colon, thing. Just know that you're drilling in deeper into submodules to pull something out rather than it being some sort of weird syntax.

Scott Tolinski

So, you know, oftentimes, that that that colon colon, I think, can, like, really throw people off when they're looking at Rust it. Because it looks so foreign for some people who are used to either doing a forward slash or a dot in JavaScript. Right? Yeah. That's actually one thing I found about Rust

Wes Bos

Versus other languages is that I can read it. As a JavaScript developer, I can jump in and reason about it pretty easily, which is not necessarily The same for other languages that have different syntax or different order of operations.

Wes Bos

So that is one of the weird things.

Scott Tolinski

What is these Colons for Yeah. Well, this can be the last thing because we're getting into, 29 minutes here and then we can, you know, like I said, there there's us so much here at a high level for JavaScript developers. We could spend a few episodes going over all kinds of things. So While we're here talking about this colon, we can wrap it up with, like, what's up with the double colon? Like, what is it? Like, how what does it actually do inside of RustWorld? Because you do sometimes see it in it's not just used in the import statements. It's sometimes used inside of code.

Scott Tolinski

And, I mean, often used inside of code. Us. In places in which you'd typically think like a period would be. Right? So it's basically In a JavaScript world, you're always using the period. Right? No matter what to access anything, sub sub module, method, and everything. And that's because in JavaScript, everything is an object.

Scott Tolinski

And that's not necessarily how it works here. So it's used in place of the period for name space paths, for calling functions or static methods on things or for enum values. Right? If you had an enum that had names in it, You could say name colon colon Scott to pull out an enum value.

Scott Tolinski

So it's it's used for name spacing really to pull things out of a name space Where a dot, a period is used for, accessing it. Methods on an instance of something. Right? So you create an instance. You create my string is an instance of string. Right? My string. So I have my string. And if I wanna access string methods on that you do my string dot the method. Just like you would in JavaScript.

Scott Tolinski

So you you're typically using the double colon to pull out Functions or methods on a thing where the dot is for functions or methods on an instance of a thing.

Wes Bos

Does that track? Yeah. Yeah. It makes sense. Yeah.

Scott Tolinski

So that's up that's what's up with the double double. And so you'll see it all over Rust world. Just know that It it's if you see, like okay. Here's an example for some code I just have sitting in front of me from, duration. Duration is the module. You'd see duration has been imported, then you're using duration colon colon from millisecond, from millis, and then a number, Where in JavaScript, that would always be duration dot from millis. But because duration is the namespace itself, not Like some instance of a a thing, you're able to use that function directly from duration here.

Topic 8 29:28

Double colon in Rust is like dot in JS, but for static methods vs instance methods

Scott Tolinski

Okay.

Scott Tolinski

So I know there's a lot of stuff here. But, you know, I you know, I think I wanted to give a real high level overview, especially for this first one is, like, What are the differences? And, you know, the big thing here to think about if you're looking into the Rust world is that comparatively to Node. Js or to JavaScript, Instead of having a 1,000,000,000 options do a 1,000,000,000 different things, you have a, like, a really happy path for everything. And that happy path is basically Cargo and Rust Rust team stuff. So the Rust docs, crates dot io, you have this Whole world that is kind of really encapsulated as being the way you do it rather than pick your package manager, pick your testing library, whatever.

Scott Tolinski

And those things can come in way handy when you're learning this stuff because you don't have to make those choices.

Scott Tolinski

So high level, Rust can feel very much like TypeScript at times. It can feel very much like JavaScript at times.

Scott Tolinski

It's not A super scary beast even if it can look intimidating at first.

Scott Tolinski

There are a lot of similarity similarities, But you have this cargo here. You have, the all of the happy path to go on. And if you can get a happy or a hello world it. Up and running in Ruston in no time whatsoever. You know, that is a good first step, but there is a lot of things that will trip you up along the way That I would love to get into in further of these episodes, things like things like memory, things like the the typing of things, you know, how similar it is to to JavaScript.

Scott Tolinski

The fact that we don't have everything as objects makes a big difference in how we code. So,

Wes Bos

that's exactly what I was gonna ask you. I'm I'm it. Super curious about what does an array like is do you have maps? Are there different kinds of numbers? And, we should I Probably do an entire show just on the, like, basic types of Rust. Oh, brother. Yeah. There are Oh, brother. 13 different a Thirteen different base types including,

Scott Tolinski

a ton of different integer types, 2 different flow types, and all kinds of things. So we can talk it extensively about types in another episode. In fact, I think that would be a good place to end this one because the very next thing I have in my notes here, Wes, is types, structs, variables, so we can get all of that and more in the next one where we talk about how this stuff is different than JavaScript.

Scott Tolinski

I hope that helped. Sometimes it's hard translating some of these things from one thing to another thing. But, again, it's all very neat. And, I've had a lot of fun writing Rust code myself, and and I hope to dive further and further into this this world and create some cool stuff. Beautiful. Alright. Thanks everybody for tuning in. We'll catch you in the next one. Peace. Ace.

Scott Tolinski

Head on over to syntax.fm for a full archive of all of our shows, And don't forget to subscribe in your podcast player or drop a review if you like this show.

Share

Play / pause the audio
Minimize / expand the player
Mute / unmute the audio
Seek backward 30 seconds
Seek forward 30 seconds
Increase playback rate
Decrease playback rate
Show / hide this window