👉 To try everything Brilliant has to offer for free for a full 30 days, visit brilliant.org/CodetotheMoon/ You’ll also get 20% off an annual premium subscription. They have courses on LLMs and Quantum Computing!
Other things I think will really translate for a TS dev to Rust: 1. build express server & compare to rust tokio 2. read csv, parse, run aggregations, write file (compare) 3. small cli tic-tac-toe game showing limitations of TS types & strength of Rust Traits 4. Server in-memory operations showing how GC overhead for TS can be problematic at scale, and how Rust automagically removes variables when out of scope. Example usage, aggregator API. Input request is some collection, server queries 4 other APIs, aggregates data and returns collection
I strongly disagree socks and coal are "junk". These items keep you warm in winter. Can't do that with diamonds and emeralds (unless you buy socks and coal with them).
The quality of this video is awesome! Please please make more videos like this, the length and content covered is just right. While there are quality videos out there, they end up being very long and unfocused leading to videos closer to an hour long....
Just as a tip, it might be a good idea to disable code ligatures for the code snippets, at least for videos covering fairly fundamental parts of a language. It might not be hard for people who aren't used to it to figure them out, but it is a small barrier to reading them
i watched this video while on my coffee rush. I am intimately familiar with the topics you covered in this video. Thank you so much for connecting to me on a deep level!
Super informative video, the only bit that I wasn't clear on was why the Result would stop iterating on the first error it encountered? It sort of makes sense from context but I don't know where that leaves things like the resulting vec or if you can no longer use the collection (as it's been consumed) and you can't access the elements as you only have the Err variant back? (I've been much more likely to use the Vec type so understanding the "rusty" way to do the same thing properly would be awesome!
at about 8:51 the the entry(...).or_insert_with(Vec::new) can be rewritten as entry(...).or_default() which clippy will helpfully tell you to do too :) This works because the Default impl of Vec gives you an empty vector.
More of these please B0ss 🤣🤣 I’d love to see a sectioned series covering all the traits in the std lib (and maybe some of the extension crates traits that are super popular like itertools)
@@codetothemoon some positive feedback to understand the viewer base side of things- I enjoy seeing your videos pop up and love watching them. A lot of the time I tend to be unsure of what exactly you’ll be covering though (‘direction’ if you will?) I think something like this may help give that solidified feeling that there’s a common audience goal, just some ‘food for thought’ type stuff ig Keep on keepin’ on brother 🤙❤️❤️
Good catch :) I had all the examples in one program when I was writing them, so I was using clone everywhere. Intended to remove them all for the video but this one slipped through the cracks
I looked into this and you're right! it seems like reduce can mean something a bit different in each ecosystem - for example in Rust it does not allow you to specify an initial accumulator value, and the type of the accumulator must be the same as that of the input elements. But the javascript implementation is more like Rust's fold...
Going into details: ".into()" is from a Trait Implementation, and used to explicitly convert a data type into another if it supports the conversion. Like for example, converting an i8 (Might commonly be refered as Short type in other languages) '.into()' i32 (Might be commonly be refered as int in other languages). Here in the video, `"Socks"` are actually a `&str`, which could be considered as a Wide-pointer that holds the memory address to some data plus the length of the data (i. E. How many chars can you safely read. It's kind of like Java' s Arrays, which you can find the array's length by reading the 'length' attribute) "&str" are different from "String" because the first is a "wide-pointer" that holds some memory addres + the length, whereas the second is dynamic sized array (Vectors). The String (which is a vector under the hood) would additionally hold the capacity, so you can know how many more chars/bytes can you push into the allocation, before you need to re-allocate the string in the heap to get more writing space. Short form: `String` can be gotten from a "&str", which is where CodeToTheMoon used it the most, and because he was storing Strings, and not & str's, he needed to call ".into()" because Rust doesn't do implicit conversions
This is because Rust is a low-level language so it doesn't have any garbage collector, so you shouldn't compare Rust to high-level languages such as C#, Java, JavaScript or Python, you should compare it to other low-level languages such as C, C++, D and Zig. When you compare Rust to other low-level languages you will see why the borrowing and ownership stuff is amazing.
👉 To try everything Brilliant has to offer for free for a full 30 days, visit brilliant.org/CodetotheMoon/ You’ll also get 20% off an annual premium subscription. They have courses on LLMs and Quantum Computing!
You little cheater! You implemented not listed a day before uploading and added the trait first comment before we even had a chance
@@CrazyLuke11 haha guilty as charged!
BIG YES to this kind of Rust knowledge. It bridges the gap for JS / Python devs nicely
Nice, glad it resonated with you!
Other things I think will really translate for a TS dev to Rust:
1. build express server & compare to rust tokio
2. read csv, parse, run aggregations, write file (compare)
3. small cli tic-tac-toe game showing limitations of TS types & strength of Rust Traits
4. Server in-memory operations showing how GC overhead for TS can be problematic at scale, and how Rust automagically removes variables when out of scope. Example usage, aggregator API. Input request is some collection, server queries 4 other APIs, aggregates data and returns collection
I strongly disagree socks and coal are "junk". These items keep you warm in winter. Can't do that with diamonds and emeralds (unless you buy socks and coal with them).
Touché, good point. My implicit frame of reference was an rpg-like video game, I should have made this clear 😎
The quality of this video is awesome! Please please make more videos like this, the length and content covered is just right.
While there are quality videos out there, they end up being very long and unfocused leading to videos closer to an hour long....
Thank you, really happy it resonated with you!
Just as a tip, it might be a good idea to disable code ligatures for the code snippets, at least for videos covering fairly fundamental parts of a language. It might not be hard for people who aren't used to it to figure them out, but it is a small barrier to reading them
Thanks for the feedback, this is something I hadn’t considered!
Thank you SO MUCH for this video! It finally cleared up the confusion about all this iterator stuff!
nice! really happy you got someting out of it!
Thanks! Really good explanation of collections and iterators!
Glad you enjoyed it!
i watched this video while on my coffee rush. I am intimately familiar with the topics you covered in this video. Thank you so much for connecting to me on a deep level!
nice, really glad you liked it despite already knowing much of the content!
Super informative video, the only bit that I wasn't clear on was why the Result would stop iterating on the first error it encountered? It sort of makes sense from context but I don't know where that leaves things like the resulting vec or if you can no longer use the collection (as it's been consumed) and you can't access the elements as you only have the Err variant back?
(I've been much more likely to use the Vec type so understanding the "rusty" way to do the same thing properly would be awesome!
My favourite rust feature is exactly this.
The type system and other features that accomodate it.
Agree, the Rust type system is amazing 🤩
I love this channel
Taught me so much stuff about rust.
I always recommend it to other people who learn rust
Thank you so much
awesome, really happy you got something out of it! and thanks for the kind words!
Very nice explanations of some basic concepts that trips people up. More of this type of content please!
thanks for the feedback, will do!
at about 8:51 the the entry(...).or_insert_with(Vec::new) can be rewritten as entry(...).or_default() which clippy will helpfully tell you to do too :) This works because the Default impl of Vec gives you an empty vector.
More of these please B0ss 🤣🤣
I’d love to see a sectioned series covering all the traits in the std lib (and maybe some of the extension crates traits that are super popular like itertools)
nice, glad it resonated with you! and great idea!
@@codetothemoon some positive feedback to understand the viewer base side of things- I enjoy seeing your videos pop up and love watching them. A lot of the time I tend to be unsure of what exactly you’ll be covering though (‘direction’ if you will?) I think something like this may help give that solidified feeling that there’s a common audience goal, just some ‘food for thought’ type stuff ig
Keep on keepin’ on brother 🤙❤️❤️
Cool, Rust is powerful thanks
Indeed, thx for watching!
4:01 I don't think you should use clone there 😂
Good catch :) I had all the examples in one program when I was writing them, so I was using clone everywhere. Intended to remove them all for the video but this one slipped through the cracks
Please more videos like this 🙏
Will do!
I did not know about or_insert_with. That's going straight to the pool room.
Nice, glad you got something from the video!!
thanks a lot for the good work, the beard is awesome 😎 sir
thanks for watching, and thank you!
thank you
Glad you liked it!
Liked the video just for the thumbnail
Hah thank you!
What did you use to animate these code snippets?
Animotion, created by the fellow who runs the “Joy of Code” channel! Fantastic tool.
fold is similar to array.reduce method in javascript.
In C# you have the Aggregate method which I believe is similar.
I looked into this and you're right! it seems like reduce can mean something a bit different in each ecosystem - for example in Rust it does not allow you to specify an initial accumulator value, and the type of the accumulator must be the same as that of the input elements. But the javascript implementation is more like Rust's fold...
can~t still understand, into~thing
If you can tell me what part you’re stuck on maybe I can clarify a bit!
Going into details: ".into()" is from a Trait Implementation, and used to explicitly convert a data type into another if it supports the conversion. Like for example, converting an i8 (Might commonly be refered as Short type in other languages) '.into()' i32 (Might be commonly be refered as int in other languages).
Here in the video, `"Socks"` are actually a `&str`, which could be considered as a Wide-pointer that holds the memory address to some data plus the length of the data (i. E. How many chars can you safely read. It's kind of like Java' s Arrays, which you can find the array's length by reading the 'length' attribute)
"&str" are different from "String" because the first is a "wide-pointer" that holds some memory addres + the length, whereas the second is dynamic sized array (Vectors).
The String (which is a vector under the hood) would additionally hold the capacity, so you can know how many more chars/bytes can you push into the allocation, before you need to re-allocate the string in the heap to get more writing space.
Short form:
`String` can be gotten from a "&str", which is where CodeToTheMoon used it the most, and because he was storing Strings, and not & str's, he needed to call ".into()" because Rust doesn't do implicit conversions
Longest 12 minutes video. To fully understand, watch/listen multiple times.
Thanks for the feedback. Would a slower pace have been better?
@ No, the pace and the delivery are good. The topic is not an easy one.
Noice!
Thank you! 🙏
Second 🎉
Nice!
Third! yay
Nice!
I don't like Rust just because of ceremony of writing borrowing, ownership fluff.
Understandable!
This is because Rust is a low-level language so it doesn't have any garbage collector, so you shouldn't compare Rust to high-level languages such as C#, Java, JavaScript or Python, you should compare it to other low-level languages such as C, C++, D and Zig. When you compare Rust to other low-level languages you will see why the borrowing and ownership stuff is amazing.