ERRATA - The borrow checker is explained in my previous video "Rust makes you feel like a genius" (many people missed it) - Void functions actual return an empty tuple `()` which is pronounced "unit". - Reading a variable before it is initialised in C doesn't crash, it's undefined behaviour WHICH IS WORSE OMG - (1..) to my great disappointment isn't infinite, it's bound by the iterators internal i32, which is up to std::i32::MAX (2,147,483,647) - Missing semicolon on line 5! - i32 is difficult to liken to C's long, it's architecture-dependent. - 5:11 though this compiles, it should be `fn is_positive(&self)` to avoid the method taking ownership of the self doc.rust-lang.org/book/ch05-03-method-syntax.html - 2:35 - `assert!` should be `assert_eq!` - 9:31 `flat_map` or `map` both work in this example - 7:13 Error says `OErr` where it should be `Err`
This is exactly what I want to see in a tutorial! No 30 minute talk about every function a string has, but straight to the point while respecting my intelligence. Thank you!
@@NoBoilerplate I'd also love to have specific rust features explained in such concise and practical ways, i.e. traits, futures, working with cargo and toml, etc. Nothing too in-depth, just some mouth watering substance that gives you a good idea on where to start. (could basically do every chapter in the rust book like that haha)
This was incredibly helpful is what has helped me the most so far. I'm 'fluent' in several languages so I have a solid understanding of what to expect from languages. So many videos start from the ground up, and spend 10+ minutes explaining just a single concept or two. Skipping through video after video (or article after article) just to learn the basics is exhausting. That's why I appreciate this video so much. It's not to intended to be fully comprehensive but to provide people (like myself) a bridge between their existing knowledge and how to use Rust. I came away from this video feeling like I could write a nice simple 'hello world' type of application without having to look up 'how to write a function in rust'. Dense videos like these take a lot of time and energy to create, so just wanted to say a huge 'thank you' and share how much it's helped me. The resources that you've linked are just as helpful. Thank you!
My pleasure, and I'm so pleased the videos help you out! My aim is to get as many people into Rust as possible, because it's really revolutionary - not just for C developers tired with bugs (as the common wisdom is) but ALSO for high-level developers (such as me, a python web dev) wanting to write perfect code. Have you seen my previous videos? Rust has a steep initial learning curve. It's going to be a HARD job to get through a few pain points. Here's two you'll hit: 1. Two string types!? 2. Lifetimes And when you hit these rough days, you'll need a boost. My previous 3 videos are designed to remind you that not only is Rust exciting, but it's the only language you can do these amazing things in. Watch them when you need motivation. Good luck! (My recommendation is for 1. is to use String (not str) everywhere, and 2. you can sidestep by copying everything. .copy() .copy() .copy() who cares, optimise later! OR NEVER)
Reading from undefined memory doesn't always crash at runtime. It's Undefined Behavior. Most commonly it either crashes or gives garbage data, but its allowed to do literally anything, including make demons fly out of your nose
Owen! Thank you so much, you're so generous - but there IS another resource for rust: please do visit fasterthanli.me where the source of this video is taken from. Amos does SUCH great work on his site, he makes videos too, but his articles on Rust basically TAUGHT me the language! Thank you again :-)
@@NoBoilerplate I absolutely will! This is a great resource for people picking up the language. It can be hard to do that initial read-through of the rust book without your eyes glazing over a bit when you don't have the full context about why certain features can be useful or if the language is right for you. Being able to get a super quick set of examples like this showing how rust code works and some of the features is incredibly helpful as a primer for the rust book.
The whole point of my channel :-) Here's a few more Rust videos of mine that I'm proud of, all in the same fast style: ua-cam.com/video/oY0XwMOSzq4/v-deo.html
I thought I would be able to understand this video since it’s like “lesrn rust in 10 mins”, then he starts saying things like “MATCHES MUST BE EXHAUSTIVE”, WHAT THE FUCK DOES THAT MEAN?!?!?!
@@TheBlackmanIsGod btw if you are really curious, "exhaustion" in this context means "check all possibilities", when something is #[non_exhaustive], it means that you can't check for all possibilities and you need a "fallback" case
This is that video which assumes I am well versed in C, and now I want a quick crash course on getting up to speed with rust syntax. I rarely find tutorials like this. Every body starts a hello world program and spends 30 minutes there.
Terrific: for someone new to compiling to web assembly using rust, I really appreciate how much you pack in. Agree that borrow-checker and lifetimes best separated out to another video. Rust is such a welcome evolution to programmers, improving the reliability of the programs we write!😀
This video is truly awesome. Nowadays is very hard to find concise and good selected content about a language in only 10 minutes. We all know we won't learn the whole language in 10 minutes, but as someone who also just dives in the languages and takes its time to learn, this video cleared a lot of concepts about rust syntax (like reading and understanding the generics for functions and structs, or the '?' operator, or simply the '!' character that represents macros), it helps so much to understand what is written.
I have been programming in different languages for 20 years+ and no language has ever made me fall in love again with creating software as much as Rust. If you code, you owe it to your heart and soul to check out Rust. Thanks for the amazing content in this channel by the way!
Wonderful! I am delighted. Do watch my other videos (especially Rust is Boring) to get excited about WHY we are learning this complex language . The rust book is great too!
Math and programming are somewhat intertwined. Think of programming as "Math automation". You write the "math formula" as code, declare variables, and the computer "computes" everything else. Programming is a great tool for math majors especially if they had to deal with the same math formula with different variables.
I'd heard of Rust, but didn't know what it was like. I didn't want to go through an hours long video describing every detail. I just wanted to get a sense of what it is like. This video gave me what I wanted. Thanks for doing the work.
My pleasure. This video focusses on the syntax specifically, which isn't quite the whole picture, check out other videos in my rust series, such as ua-cam.com/video/4YU_r70yGjQ/v-deo.html
I started learning Rust and then sorta gave up and just picked it back up only after rewatching your previous videos on Rust for motivation, this was perfect, thanks!
My friend, this warms my heart. My EXACT REASON for making these videos is because Rust was so hard for me to learn. I crashed out a few times, and only was able to get through it because I had a mentor helping me through it. I am hoping people can re-watch my videos for a boost!
@@NoBoilerplate Your videos are short but highly technical, usually there is a trade off between length and technical depth. For me personally it provides that quick motivation from a shorter video and gets my curiosity going because of the depth. I had seen the impl keywords but didnt know what they did in that short span where you explained tham, I opened up a temrinal and messed around with the impls. Keep them coming! You're doing a fantastic job
3:04 void is very C-ish. Verbally "void" is... acceptable, but the top function here does not return "void". The type is actually called "unit" and written with the empty parens (). Just writing the notation correctly would be fine imo, but this should've had a short note that the top function is equivalent to -> () and explain that "unit" is just the empty tuple and has one value, and not some special type without any values used to denote no return value
Maybe, but I'd hazard a guess that the vast majority of programmers understand "returns void" as "returns nothing". C, C++, C#, Java and Typescript are all extremely common and well known languages so it's totally reasonable to use their terminology even if it's not technically correct for Rust (because ultimately it has the same effect).
Very helpful content. I can’t even state how much I appreciate this format. Please make more high speed basics videos for rust. Or whatever. I’ll watch.
Thank you so much! I will. Video 11 (of this new format) arriving on Thursday. I may soon add another video, making my videos weekly, not on Rust, but on other interesting technical topics. Stay tuned!
I started on this video and had to go back and watch the previous 3 videos of the Rust Talks playlist. Excelant information throughout and very worth while the time it took to watch them, certainly no second wasted, I like that. I need more of this straight to the point, no BS technical talk that also explains everything you're seeing in code snippets. I've tried other videos before finding these, but they always gloss over small things like the difference between the tail expression of a function lacking a semicolon and explicitly returning a value from it, in which I now know there is no difference. I always get sidetracked by the little things which hampers my learning and causes frustration because I don't understand a bit that wasn't clear to me and therefore can't move on, yet the video is usually miles away from that topic by that point. I've learned more in this 10 mins than I did in a couple of days of watching various videos, reading the Docs (which seem great once you understand half of what you're reading 😂) and experimenting with code. I now know to make great use of struts and matching, and that iterators exist which is something I'm already quite familiar with in other higher level languages. This is my first deep dive into a low level language and you've certainly made it a much more pleasant start than I could have asked for. I look forward to more videos, thank you!
My absolute pleasure. Try: - The Rust Book (link in the description - Rust By Example - Rustlings (code katas) - everything fasterthanli.me has written!
Found your channel a couple of months ago. Love the rust videos. They inspired me to look more into the language and its awesome. Please keep those amazing vids coming
Thank you so much! I'm having a great time writing these, and it's really helping solidify my own Rust knowledge (not least because when I make mistakes, people correct me!)
The correct adjective for this presentation is Gangster. I just had to listen to rules i agree or disagree with and take it. But there weren’t any opinions on the rule. That’s just what it does when it do what it do. Feelings to your self g. This just is what it is. I love it so much.
@@NoBoilerplate ha. Must have been tipsy when I left that comment. What can I say? I love code so much I watch videos on languages I don’t use when intoxicated for fun. Glad my dubiously professional grammar didn’t miss the target.
This is so good, I'll be sending this to anyone who asks about rust! Have you thought of part 2 for things like lifetimes and the ecosystem (crates,cargo,docs,test)?
Thanks for the video and reference, it's immensely helpful to anyone who wants not to program in Rust but sees that working with programs written in Rust is the unavoidable future.
@@NoBoilerplate Sure thing! I do like the language and the feel of it, and really enjoy Helix, nushell, Redox and whatnot, but it wouldn't benefit me to write in it more than in it would to write in Nim (which I'm already learning as I've found it most versatile on top of also being fast and safe). So yeah, I'll surely take pleasure in learning at least to read, understand and interface with Rust. PSst, my favourite language-in-the-making's compiler is actually being written in Rust! Can you figure which one that's gonna be?
@@gimlam5909 Love Nim. My only concern is popularity, which in the software development world is a HUGE factor that I can't ignore. If I were to ignore popularity, I'd probably have written these vidoes about Haskell, which I love, but I can't hire for.
Thank you very much for you kind words. I don't know if I will do ads in the future, something on-topic in the middle of the video that is relevant to my audience perhaps. I suspect I could do more videos if I was sponsored - but I also find ads annoying! I'd love to know your opinion here, and thank you again.
Wonderful. I've mostly ignored rust as at work we are so c and c++ heavy. Seeing this made me think a lot of the Swift updates over the years and I can see how Swift is influenced by Rust. Thanks again for this video as it is exactly what I need.
4:23 well except for wildcard imports ``use std::*;`` and the prelude items (including importing crates, ``std`` is available despite not declaring ``extern crate std;``)
I didn't understand everything completely, but its really nice to have an overall idea of what i should expect in my learning, journey. This type of content is as helpful as a detailed video, i hope you keep making these type of videos. Good job and thank you so much
Very small correction : on most platform, long has 8 bytes, while int has 4 bytes in C and C++. Thus i32 refers to int or int32_t if you want to be really exact. Other than that, excellent video.
> int has 4 bytes in C and C++ Also incorrect. int is defined to be at least 16-bit whereas long is defined to be at least 32-bit. So while int is indeed 4 bytes on a lot of platforms, the standard doesn't define it that way.
I could be wrong, but I don't think that's the case. In Java, you would be right, int is 4 bytes, long is 8 bytes. In C/C++ though, long is 4 bytes, long long is 8 bytes, and int is determined by your architecture. If you're on a 32 bit computer, int is 32 bits aka 4 bytes. On a 64 bit computer, int is 64 bits aka 8 bytes. If you're somehow on a 8 bit computer, int is 8 bits aka 1 byte. The architecture thing is also like isize/usize in Rust
@@zperk13 I don't think I can link anything here, but let me quote Wikipedia here: > The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits. You can also find these in the actual C standard here: 5.2.4.2.1 Sizes of integer types
@@zperk13 yes, this is the case on many embedded systems. There are lots of things like memory alignment and specialized instructions that are system compiler specific and make these subtle things like data type sizes a bit complex. It all comes down to the computer architecture.
Wow I feel better for getting this wrong - what complexity! You folks seem like you might know the answer to this: Is i64 faster than i32 on typical desktop 64-bit system? Another commenter said this. If so, maybe I should recommend i64s?
There's low demand for rust right now but I hope there will be. The language and tooling is excellent! I find that one can significantly cut down cloud computing and upkeep costs if they switch to rust. It's good for the environment as well. AWS has started to support more rust so I think we'll find more demand for rust soon.
Most of the Big Tech companies are in the Rust Foundation, so I would expect It to grow significantly over the next few years. WebAssembly may prove another sweet spot for high-perf applications in the browser client.
Literally the point I hit the roadblock, its like the language is constantly trying to throw away everything you see unless you explicitly state that you need to keep it.
@@someonestolemyname what? That sounds like you gave up after 5-10 minutes of messing with references and move semantics, and never got used to it to see if it actually makes sense or not.
@@Anon.G and those safety restrictions means that you might end up in situations where you think it should work, because it would work in all other languages that you know, but it doesn't in Rust. This is even more confusing when you start composing your own types with structs and enums and they might contain (directly or indirectly) references and you need to be careful to place out all the lifetime annotations correctly. Furthermore, when you start including traits and heap allocations in to the mix then it can become a nightmare compared to other languages. Have you ever implemented a factory pattern in Rust? It took me over a day to figure out why my factories had to be singeltons for the borrow checker and lifetime checker to be happy.
Talking nearly 10% of the video’s duration about how this video is boilerplate-free and straight to the point! That’s exactly my type of humor! 😂 Great video, though! 😊
Every day's a school day! Yes, another commenter pointed this out, that's great news. I already use `const`s exclusively in my js, it's wonderful to know they're even safer than I thought!
I would be very interested to get your take on Vlang and Zig, two languages that seem to be vying for a similar space as Rust. All three are meant to be extremely performant by ditching a Garbage Collector, but similarly avoid the gaping pitfalls of manual memory management. Of course, in most situations, it's not really accurate to say "X language is the best, objectively better than Y language." I personally lack the experience to do a full breakdown of what each language offers to the developer, which projects benefit the most from each language's best features, and so on.
oh COOL! I'd not read up on Vlang. Looks like a great little low-level language inspired by Go. HOWEVER it has a GC, which means I can already tell many things about the language: - No embedded development - Can't write linux modules - Imperfect for hard realtime applications (music, flight control software, ETL pipelines) - No borrow checker superpowers I wonder who this is for? A Go developer wanting lower-level code? Then why does it also have a GC? Hmm. Cute though! Zig I love - huge huge fan. It really helps you manage memory in a sane way, and the whole language has no surprises. But the kicker is you still must do it, and you might forget. Zig is certainly a better C, but they didn't try to push the envelope. Rust's lifetime annotations and borrow checker are a FEATURE, not a burden. A rich type system is great, but if you add lifetimes to the types, you've enriched them in ways that don't just mean the compiler can manage memory for you - you can build your own types with complex temporal logic in. One day I'll do a video on this XD
@@NoBoilerplate *Interesting!* I'd come across some performance benchmarks where Vlang would actually beat out Rust, and I found no mention of a GC, so I just kind of assumed there wasn't one. Impressive for them to reach that kind of performance with a GC, even if it's not really swinging for the same ball park. And I'd be very interested to see that video 😁
@@chrs-wltrs I admit I didn't get further than the front page, where they mention it! Apparently there's a new mechanism that can statically free 90% of memory cases, leaving the last 10% for GC. While that is terrific, I am left wondering how much time they're going to invest in an imperfect solution XD As for performance, Rust benchmarks in 1.1x C's speed (Java and JS are 4, Ruby is 20 and Python is 80). So while I can believe it, rust is fast enough!
Very nice! I have a few coworkers that are trying to learn Rust after I have been praising it for a year. This will likely remove the "I don't have enough time to start it" excuse!
Amazing! Do give them the linked article that I based the video on - I know some people prefer reading (and copy and pasting!) rather than a video. Also, make sure you've seen my previous 3 videos on Rust - they're about the incredible features of Rust that you can't get anywhere else!
It means the function receives read-only access to the argument. It's called immutable reference. There's also &mut which takes write access. Without any prefix, the argument is taken by value, which means the function consumes it (unless the type is Copy, in which case a bitwise copy is passed in).
I'm happy to learn that my F# algorithms can be ported to Rust with just some minor syntax adjustments. Immutability by default, Ok/Error constructs, optional types, lazy expression evaluation, type inference, etc. And it's even possible to bring partial application and JSON type providers with 3rd-party packages, aka "crates"! From "I wonder what's the hype about" to "I should def try Rust out" in just 10 minutes.
oh you're gonna LOVE it. Yes, the `partial` crate is a vital part of my workflow! I think they snuck the best of haskell and the best of lisp into the cool kids party, wearing C's clothes!
tuples were weird for me because python tuples are immutable but rust tuples are mutable, but man tuples are powerful, its like a struct but without needing to make one
@@NoBoilerplate I think so, too. Go relies a lot on Tuples since it doesn't have enums. After thinking more about it, I mainly use tuples when wrapping a type (New Type pattern afaik)
@@CunningBard Yeah, a pair of things is often OK for a tuple. In Rust, I find I'd rather name it and call it a Struct so that I know what KIND of paired data I'm working with. Javascript has made me afraid of anonymous blobs of data
I was confused by 3:30, where the "tail" of the declaration block is: "y + z". To the uninitiated, this almost looks like a function without a return type, and in other languages I've not seen this type of compound assignment. It took a moment of staring to realize the tail isn't a void addition that can be read by itself, but has to be resolved in your head then "returned" to the first line. It might have helped to put an example print statement or comment showing "x" is now "3". Cheers.
It's because I based it on the best blog introducing Rust :-D I send people my previous video on rust as the best introduction I could make: ua-cam.com/video/IA4q0lzmyfM/v-deo.html&
3:04 - I wouldn't write "f -> void" if i were you. I'd use the proper type, "fn() or fn() -> ()" for consistency, and further explain that "() is a struct with no values. it is a unit struct, because it can only have one state; existing. it means void.".
I'm trying to create a programming language and I can't decide between using c++ or rust. I've tried doing some stuff in both, but it was a little difficult to do what I wanted with rust. No classes, can't assign references in structs without destroying the code with lifetimes and had many other problems while learning rust
Rust is certainly more difficult to learn, but it is WORTH IT! Have you watched my other videos on rust? In them I explain the unique features that you won't find anywhere else.
Yes, this is typical experience when starting to learn Rust, particularly for people coming from OOP. Rust is not the kind of language where you learn to translate syntax from language X, and you're good to go writing your code in whatever style you like. Rust has its own "coding paradigm", that's somewhere in between functional, OOP and imperative. You tried to do some stuff in Rust, and it was difficult to do what you wanted, THE WAY YOU WANTED TO DO IT! That's the problem. It took me about a year to learn the "Rust way of doing things". Unfortunately, I still can't fully explain what that is exactly. Especially not in a single youtube comment. People describe it as "becoming friends with the borrow checker", but never really describe how to get there.
@@NoBoilerplate Of course I did. That's why I decided to learn it :) It is great because you can make no mistakes in your runtime because of rust if you use it the right way, it will have a difficult learning curve because of that, but like you say: it's worth it.
@@KohuGaly A year of learning is too extreme for me. I think I can learn it quicker, thanks to modern IDEs, but if it's worth in the long run, that's another question
i was looking for this thank you for making this video if possible please make a series of tutorial for rust for the people who already know some programming language
In C/C++, the semicolon is not a mandatory white space, it is a statement of itself, which can be compiled into a NOP (no operand) instruction when needed, it is upto the compiler to do so or not due to compiler optimizations. Think of an empty for or while loops that do nothing, based on C/C++ language specifications, they require at least 1 statement, if none is needed, an empty statement can be used, a semicolon. 👍🏻
@@robbietorkelsonn8509 It's becoming clear that the Object Orientation experiment has not been a wild success. Note that Reactjs and those like it use a functional reactive paradigm!
Thank you! All my videos are like this, here's another in the playlist if you've not seen it, I'd love to know what you think: ua-cam.com/video/sbVxq7nNtgo/v-deo.html
I also like the short and dense format, although I felt there were places where the examples were confusing for beginners and a bit more explanation would have been very beneficial. For example, I wish the video had explained what |c| meant.
I feel that rust is one of those languages where you need a knowledgeable mentor in the early days. I had a go at writing sha256sum in rust, and there was a lot of head-scratching and digging around to find out how to do things. Whereas in Python and C it was relatively straightforward. I say mentor because, when writing 'worked examples', you're guessing what the novice programmer wants to write. But rather, you need to start with a novice programmer who knows what they want to write, and then guide them as to how to write it in Rust.
You've got it exactly right. Back in 2020 I crashed out of learning Rust twice. First time due to multiple string types (haskell's biggest mistake made again, I thought to myself) and second due to lifetimes. At the time I had a great mentor (Shout-out to Alex!) who picked me up and helped me back on the path. Most people don't have this. They need the excitement of my hype videos to break through. I will eventually run out of hype topics and move on to slightly more detail. But first, there's a few million developers I want to send to rustup.rs!
@@NoBoilerplate I've been learning rust recently, and chatgpt has been a great mentor. If I'm getting an error I can't make sense of, I can copy paste the offending piece of code and the error message, and like 80% of the time it tells me why it doesn't work. I still have to rely on traditional methods for the other 20%, but it greatly reduces the amount of head scratching I go through. It's been a bit of a challenge though, since nearly all of my experience is in C# and Python. I've never used a low level language before, so the learning the intricacies of low level + the intricacies of rust simultaneously has been challenging. I've come pretty far though!
@@sa1t938 oooh that's INTERESTING! I'm in deep with chatgpt, and I'm SUPER excited and scared for what 2023 is going to be like, with this tech revolutionising every single field!
I find writing C unbearable. Too low level, too much UB and too little abstraction facilities, unless you (ab)use the preprocessor. C++ is kind of OK but a real beast to tame...
That's actually worse than if it just crashed. It means your C program may silently corrupt arbitrary memory. That's one of the worst kinds of bugs you could encounter.
It depends, some machine code generated by MSVC (and others) for x86 regarding i64 operations is inefficient and improperly considers microcode implementations
Thanks for this great video! I played around with rust before but haven't really looked into how the Result type and iterators work, now I want to create a small project somehow utilizing those :)
LOVE the result type - you can iterate through a result, imagining it is all working fine, and only handle the error right at the end, with a final .unwrap() (or equivalent). Do check my previous 3 videos for more explanation on this!
I liked the idea of rust but have no experience with it I loved when I used functional features like match case and expression instead of return in Scala This video makes so much sense, thank you. I like Rust now, just need to convince the boss typescript isn't the answer to everything
Typescript is certainly 100x better than plain Javascript! But yes, ideally you'd get some rust in. Have you seen my previous videos? The "perfect" and "genius" videos might persuade your boss :-)
I might have invented that, though there is a doc.rust-lang.org/std/slice/struct.Split.html I copied Amos's examples for the video here fasterthanli.me/articles/a-half-hour-to-learn-rust perhaps that particular line is psudocode?
* cherry picking time * python: uses self notation, self is passed as an argument rust: uses self notation, self is passed as an argument python: has Self type (3.11) rust: has Self type python: has lambdas rust: has lambdas python: has match statement (3.10) rust: has match expression python: has async-await rust: has async-await python: supports custom event loops (things that execute async), unlike JS rust: supports custom event loops python: built-in C interface (as CPython is the most popular Python implementation) rust: built-in C interface python: has context management ( __ exit __ ) rust: has context management (Drop) python: supports b"bytes" syntax rust: supports b"bytes" syntax python: native support for AST modification (ast module) rust: native support for AST modification (procedural macros) python: has _ rust: has _
@@-parrrate counterpoints: a) I have dabbled in other languages for fun/uni but only really properly know python b) I barely know anything about rust (have never actually coded in it myself, only heard good things from friends) (but cool to know it has all those things too) c) it's a throw away comment on a yt video, I don't have the time or will to research everything I say 100% d) (not really a counterpoint) you mean nitpicking not cherry picking I think? Nitpicking is pointing out little flaws in something, cherry picking is deliberately excluding points that don't fit your arguement. (Tbf you can do both I guess but saying you're cherry picking a) doesn't fit and b) implicitly weakens your arguement)
@@-parrrate It's still very valid to say that Rust is a different way of thinking lmao. I've used Python and JS a fair bit and even with TS, I've still not had to worry about the particulars of `str` vs `String` or borrowing or ownership at all. There's a reason why the "higher level" languages are often used more by beginners.
Rust and python make good choices about many things. I've used python professionally for 15 years, but it's time to move on. The GIL is terrible for python's concurrency, and it benchmarks 80x slower than rust in single threaded tests. Python's ast does runtime modification, macros are compile time modification - a very different beast.
I've been writing python professionally for 15 years, and I think it's time for me to move on. Rust was just familiar enough for me to learn, but it took me a while. That's why I'm making these videos, do watch the others!
halfway thorugh the book, rust is really amazing. so modern and fun, programmed a lot of stuff with it that i did to learn the classic languages 10 years ago, just for fun. it is so much fun to use
That's a very useful video, although, I didn't understand most of it, lmao. At least now I will go to the rust book and read it all, because what you showed is peeking my interest a lot
@@NoBoilerplate Yes, I watched every of your Rust related videos and really enjoyed them, that is why I got recommended this video. Thanks so much for making them btw
@@NoBoilerplate I meant the multiple return statements in a function, certain C linters will warn about it and recommend to set a variable in the multiple branches and have it returned by one statement at the end of the function. I'm just wondering if the Rust compiler would warn about the same. But I'm gonna try it out for myself 😊
@@themohmand oh! The Rust linter (clippy) has LOTS of help with using return statements, including redundant else blocks, unneeded return statements, and far far more! Check out how friendly it is in this video: ua-cam.com/video/CJtvnepMVAU/v-deo.html
Let me set the record straight: It's LISP and Haskell sneaking into the popular kids party wearing C's coat. Try out ua-cam.com/video/4dvf6kM70qM/v-deo.html next and let me know what you think!
The same thing happened to me when I read the article this video is based on, from fasterthanli.me! Continue your journey of discovery here, I've got a short rust intro playlist, not just talking about the syntax: ua-cam.com/video/oY0XwMOSzq4/v-deo.html
On one hand, the compiler being this pedantic over almost all the things is fantastic since most "throw away code" is something you actually NEED to throw away and some crude prototyping can happen during compile time instead of runtime. On the other hand, I think you can make some specialized logic based reprap that creates stubs and fake integrations before you move onto creating the "official integration" in some other language that maybe less concerned with some forms of errors that _may_ be caught in Rust before deployment. At least you won't have to deal with the type signatures made famous in that "American Psycho" business card parody of Rust functions from theSTEMgamer XD
If you can create a lambda calculus in Prolog, you can also create dependent types in this language. maybe_fopen(_, _, -1, invalidFile(E)) :- E = 'Could not open file'. maybe_fopen(PATH, FLAGS, FD, RESULT) :- ((string(PATH), string(FLAGS)) -> (integer(FD) -> RESULT = validFile([PATH, FLAGS, FD]); RESULT = invalidFopenReturn('File descriptor must be integer != -1')); RESULT = invalidFopenArgs('Path and Flags must be strings')). When you query for the result of this call like: ?- maybe_fopen("/tmp/foobar", 36, -1, R), print(R). You now get ALL the possible ways this specific function call with these specific arguments can fail, including the -1 file descriptor AND the invalid argument types. I'd say Prolog and similar constraint solvers in the logic programming space are one of the better tools for high level blueprint coding that can also be interactive since prolog can import and run these scripts inside of a REPL. This might be a great starter for automatically generated tests with functions/predicates in this kind of dependently typed domain, since it's cheaper to change the code up front at design time rather than review/production release time. Jarble's transpiler on github and Warren's abstract prolog machine would be great study materials if you're more interested in the topic.
@@NoBoilerplate between these videos and Lost Terminal, allow me to politely but strongly disagree, you deserve all these subscribers and more! Humility is a great thing but don't down play your good work unnecessarily either 😊😊
@@NoBoilerplate Well, you seem really quite skilled at condensing complicated topics down to understandable, short videos. The closest example I can think of would be Fireship or (, though it’s not on the same topic,) CGP Grey. For reference, they have 1,4M and 5,43M subscribers respectively. Until you have at least a hundred thousand, I’d consider you underrated.
Thank you so much! They're not really anything special, the trick is I PRACTICE them a lot. What's a few hours of practice for me, to thousands of hours of everyone's time? Seems rude not to!
@@NoBoilerplate Never tried it, but I plan to soon. It looks awesome. It's like Electron but using much lighter weight Rust for backend, glue logic, and a browser-like front end interface. It claims to have the ability to glue other runtimes into the same binary, like Node.js, Julia, and Python, to mix and match polyglot tech stacks relatively easily. I've been intermittently looking into whether I can use it to have Python & Pyscript do the front end UI stuff, with Rust in the back end to handle all the heavy data crunching and OS interactions, while sidestepping the staggering binary size & memory footprint bloat that comes with using chrome/electron. It seems possible. As soon as I can make the time I really want to make a network mapping tool, because Visio is a crime against UX design, and it's looking more and more like Tauri would be the best way to do native application development.
@@NoBoilerplate I'm not sure... I'm still just "Rust curious"... I've compiled once and had a fight with the borrow checker.... I know closures from JS and I say to people who like to use JS like it has classes "no... closures are beautiful".... I'm currently doing some Kotlin (more because I need an Android app than any specific desire for Kotlin) and I'm looking forward to my first closure there. I've got an embedded project on the horizon that would be nice to do in Rust..... but I'm still only "Rust curious" at the moment... I wonder if Antartica speaks Rust?
@@edgeeffect Rust has both first class functions and higher-kinded functions, you'll find just the functionality you want! Nice LT reference! In my mind, though I don't mention it too much in the show, AIs are written in LISP, and speak native Lojban (pronounceable mathematics, look it up!)
ERRATA
- The borrow checker is explained in my previous video "Rust makes you feel like a genius" (many people missed it)
- Void functions actual return an empty tuple `()` which is pronounced "unit".
- Reading a variable before it is initialised in C doesn't crash, it's undefined behaviour WHICH IS WORSE OMG
- (1..) to my great disappointment isn't infinite, it's bound by the iterators internal i32, which is up to std::i32::MAX (2,147,483,647)
- Missing semicolon on line 5!
- i32 is difficult to liken to C's long, it's architecture-dependent.
- 5:11 though this compiles, it should be `fn is_positive(&self)` to avoid the method taking ownership of the self doc.rust-lang.org/book/ch05-03-method-syntax.html
- 2:35 - `assert!` should be `assert_eq!`
- 9:31 `flat_map` or `map` both work in this example
- 7:13 Error says `OErr` where it should be `Err`
It would be helpful if this was pinned. Great video by the way.
Have you ever heard a language called "vlang" ?
@@user-rg1jp2us4o Thank you - pinned. This is the SECOND time I was sure I pinned a comment and youtube has forgotten about it. HMM
@@mixwood1130 I've not! (which is already a problem lol) But it'd love to hear about it?
C could crash, but sometimes it doesn't and that's actually worse too.
This is exactly what I want to see in a tutorial! No 30 minute talk about every function a string has, but straight to the point while respecting my intelligence. Thank you!
That's what I'm here for - fast, technical videos! What would you like me to do next?
@@NoBoilerplate More Rust, maybe ideas of projects to try out
@@rachydamine9458 Righto!
@@NoBoilerplate
I'd also love to have specific rust features explained in such concise and practical ways, i.e. traits, futures, working with cargo and toml, etc. Nothing too in-depth, just some mouth watering substance that gives you a good idea on where to start. (could basically do every chapter in the rust book like that haha)
@@erifetim righto! Sounds good, noted!
I'm only here to get a gist of what Rust is about, but I gotta say, "it panics when it unwraps and finds an error" is a wonderfully vivid image
Like a skittish horse!
Here's my high-level overview of Rust ua-cam.com/video/4dvf6kM70qM/v-deo.html
@@NoBoilerplatehorses are notorious for unwrapping.
This was incredibly helpful is what has helped me the most so far. I'm 'fluent' in several languages so I have a solid understanding of what to expect from languages. So many videos start from the ground up, and spend 10+ minutes explaining just a single concept or two. Skipping through video after video (or article after article) just to learn the basics is exhausting. That's why I appreciate this video so much. It's not to intended to be fully comprehensive but to provide people (like myself) a bridge between their existing knowledge and how to use Rust. I came away from this video feeling like I could write a nice simple 'hello world' type of application without having to look up 'how to write a function in rust'.
Dense videos like these take a lot of time and energy to create, so just wanted to say a huge 'thank you' and share how much it's helped me. The resources that you've linked are just as helpful. Thank you!
My pleasure, and I'm so pleased the videos help you out!
My aim is to get as many people into Rust as possible, because it's really revolutionary - not just for C developers tired with bugs (as the common wisdom is) but ALSO for high-level developers (such as me, a python web dev) wanting to write perfect code.
Have you seen my previous videos?
Rust has a steep initial learning curve. It's going to be a HARD job to get through a few pain points. Here's two you'll hit:
1. Two string types!?
2. Lifetimes
And when you hit these rough days, you'll need a boost. My previous 3 videos are designed to remind you that not only is Rust exciting, but it's the only language you can do these amazing things in. Watch them when you need motivation.
Good luck!
(My recommendation is for 1. is to use String (not str) everywhere, and 2. you can sidestep by copying everything. .copy() .copy() .copy() who cares, optimise later! OR NEVER)
@@NoBoilerplate the Copy trait is marker. you meant .clone()
@@malbacato91 Ah! Thank you!
0:56 variable binding
1:23 choose integer type
2:14 tuple
4:43 struct
5:42 funtion
8:20 question mark operator
8:36 Iterator
Good job!
thanks
Reading from undefined memory doesn't always crash at runtime. It's Undefined Behavior. Most commonly it either crashes or gives garbage data, but its allowed to do literally anything, including make demons fly out of your nose
You're right, it's WORSE than crashing! The more I learn about cpp the sadder I am 😂
@@NoBoilerplate common experience
not the demons again...
@@VixieTSQ no known implementation has chosen that option.
"Undefined Behaviour is a good thing actually"
- The C++ cope fiend
This video is amazing, I wish there were more resources like this with programming
Owen! Thank you so much, you're so generous - but there IS another resource for rust: please do visit fasterthanli.me where the source of this video is taken from. Amos does SUCH great work on his site, he makes videos too, but his articles on Rust basically TAUGHT me the language!
Thank you again :-)
@@NoBoilerplate I absolutely will! This is a great resource for people picking up the language. It can be hard to do that initial read-through of the rust book without your eyes glazing over a bit when you don't have the full context about why certain features can be useful or if the language is right for you. Being able to get a super quick set of examples like this showing how rust code works and some of the features is incredibly helpful as a primer for the rust book.
@@theowenmccarthy Yeah! Agreed there, you saw my recommendations? ua-cam.com/video/2hXNd6x9sZs/v-deo.html
@@NoBoilerplate Absolutely, I am following along! Thanks so much for your amazing explanations
You explained (atleast to an experienced programmer) everything necessary about Rust in 10 minutes, that's something that others do for 2 hours!
The whole point of my channel :-) Here's a few more Rust videos of mine that I'm proud of, all in the same fast style: ua-cam.com/video/oY0XwMOSzq4/v-deo.html
walked in thinking this was about the videogame rust, walked out being able to hack the pentagon.
ha! I have the reverse problem all the time XD
@@NoBoilerplate At least now you know how to raid a base with Double Barrel Shotguns and C4
I thought I would be able to understand this video since it’s like “lesrn rust in 10 mins”, then he starts saying things like “MATCHES MUST BE EXHAUSTIVE”, WHAT THE FUCK DOES THAT MEAN?!?!?!
@@TheBlackmanIsGod btw if you are really curious, "exhaustion" in this context means "check all possibilities", when something is #[non_exhaustive], it means that you can't check for all possibilities and you need a "fallback" case
@@crimsonmegumin thank you for that but I’m still totally lost and that doesn’t make any sense to me.
This is that video which assumes I am well versed in C, and now I want a quick crash course on getting up to speed with rust syntax. I rarely find tutorials like this. Every body starts a hello world program and spends 30 minutes there.
Coming from several back-end languages, this video was exactly what I needed to get me started with Rust. Thank you!
My pleasure! Check out my other videos for inspiration!
Terrific: for someone new to compiling to web assembly using rust, I really appreciate how much you pack in. Agree that borrow-checker and lifetimes best separated out to another video. Rust is such a welcome evolution to programmers, improving the reliability of the programs we write!😀
This video is truly awesome. Nowadays is very hard to find concise and good selected content about a language in only 10 minutes. We all know we won't learn the whole language in 10 minutes, but as someone who also just dives in the languages and takes its time to learn, this video cleared a lot of concepts about rust syntax (like reading and understanding the generics for functions and structs, or the '?' operator, or simply the '!' character that represents macros), it helps so much to understand what is written.
Thank you! Though all credit should go to Amos, I learned Rust from him! fasterthanli.me/articles/a-half-hour-to-learn-rust
This video is amazing, the amount of information condensed in a little time is awesome and helps a lot to learn
Thank you so much! Make sure to read the source article I'm referencing, and do check out my previous 3 videos on the magic of Rust!
I have been programming in different languages for 20 years+ and no language has ever made me fall in love again with creating software as much as Rust. If you code, you owe it to your heart and soul to check out Rust.
Thanks for the amazing content in this channel by the way!
"If you code, you owe it to your heart and soul to check out Rust" Can I quote you on that? :-)
Until now, I only had a casual interest in Rush, but your short introduction was exactly what I needed to become more interested. Well done!
Wonderful! I am delighted. Do watch my other videos (especially Rust is Boring) to get excited about WHY we are learning this complex language . The rust book is great too!
As a math major in Uni, Rust notably reads a lot like advanced mathematics. Especially with the "let" keyword and infinite iterations
You're gonna love Haskell :-)
Math and programming are somewhat intertwined. Think of programming as "Math automation". You write the "math formula" as code, declare variables, and the computer "computes" everything else. Programming is a great tool for math majors especially if they had to deal with the same math formula with different variables.
I'd heard of Rust, but didn't know what it was like. I didn't want to go through an hours long video describing every detail. I just wanted to get a sense of what it is like. This video gave me what I wanted. Thanks for doing the work.
My pleasure. This video focusses on the syntax specifically, which isn't quite the whole picture, check out other videos in my rust series, such as ua-cam.com/video/4YU_r70yGjQ/v-deo.html
I started learning Rust and then sorta gave up and just picked it back up only after rewatching your previous videos on Rust for motivation, this was perfect, thanks!
My friend, this warms my heart. My EXACT REASON for making these videos is because Rust was so hard for me to learn. I crashed out a few times, and only was able to get through it because I had a mentor helping me through it. I am hoping people can re-watch my videos for a boost!
@@NoBoilerplate Your videos are short but highly technical, usually there is a trade off between length and technical depth. For me personally it provides that quick motivation from a shorter video and gets my curiosity going because of the depth. I had seen the impl keywords but didnt know what they did in that short span where you explained tham, I opened up a temrinal and messed around with the impls. Keep them coming! You're doing a fantastic job
@@frroossst4267 Well you're so kind, thank you!
3:04 void is very C-ish. Verbally "void" is... acceptable, but the top function here does not return "void". The type is actually called "unit" and written with the empty parens (). Just writing the notation correctly would be fine imo, but this should've had a short note that the top function is equivalent to -> () and explain that "unit" is just the empty tuple and has one value, and not some special type without any values used to denote no return value
Thank you! I have added this to the ERRATA pinned comment.
Maybe, but I'd hazard a guess that the vast majority of programmers understand "returns void" as "returns nothing". C, C++, C#, Java and Typescript are all extremely common and well known languages so it's totally reasonable to use their terminology even if it's not technically correct for Rust (because ultimately it has the same effect).
Very helpful content. I can’t even state how much I appreciate this format. Please make more high speed basics videos for rust. Or whatever. I’ll watch.
Thank you so much! I will. Video 11 (of this new format) arriving on Thursday. I may soon add another video, making my videos weekly, not on Rust, but on other interesting technical topics. Stay tuned!
I started on this video and had to go back and watch the previous 3 videos of the Rust Talks playlist. Excelant information throughout and very worth while the time it took to watch them, certainly no second wasted, I like that.
I need more of this straight to the point, no BS technical talk that also explains everything you're seeing in code snippets. I've tried other videos before finding these, but they always gloss over small things like the difference between the tail expression of a function lacking a semicolon and explicitly returning a value from it, in which I now know there is no difference. I always get sidetracked by the little things which hampers my learning and causes frustration because I don't understand a bit that wasn't clear to me and therefore can't move on, yet the video is usually miles away from that topic by that point.
I've learned more in this 10 mins than I did in a couple of days of watching various videos, reading the Docs (which seem great once you understand half of what you're reading 😂) and experimenting with code. I now know to make great use of struts and matching, and that iterators exist which is something I'm already quite familiar with in other higher level languages. This is my first deep dive into a low level language and you've certainly made it a much more pleasant start than I could have asked for. I look forward to more videos, thank you!
My absolute pleasure. Try:
- The Rust Book (link in the description
- Rust By Example
- Rustlings (code katas)
- everything fasterthanli.me has written!
Perfect intro. Just researching rust for a project and all other short videos are superficial or extremely long.
Keep up the good work up!
I've got 9 other videos on Rust just like this one, check them out!
Found your channel a couple of months ago. Love the rust videos. They inspired me to look more into the language and its awesome. Please keep those amazing vids coming
Thabk you so much! I will 😁
Great to see your channel growing so much in so little time (since you became talking about Rust)
Thank you so much! I'm having a great time writing these, and it's really helping solidify my own Rust knowledge (not least because when I make mistakes, people correct me!)
Amazing! Exactly What I have been looking for. Short and concise but covers some of the most basic parts to be able to write some code.
Glad it helped! Do read the article I based it on, it's even better! fasterthanli.me/articles/a-half-hour-to-learn-rust
This is amazing! Exactly what I wanted to see for an intro to the language.
Thank you! Do check out my other videos in my Rust series!
Thank you for not dragging this out. I learn much easier at this speed.
You've actually got so quality stuff on your channel. Keep that up man!
Thanks, will do!
The correct adjective for this presentation is Gangster. I just had to listen to rules i agree or disagree with and take it. But there weren’t any opinions on the rule. That’s just what it does when it do what it do. Feelings to your self g. This just is what it is. I love it so much.
Thank you! I have a few more videos on Rust, if interested! Here's a good place to start: ua-cam.com/video/oY0XwMOSzq4/v-deo.html
@@NoBoilerplate ha. Must have been tipsy when I left that comment. What can I say? I love code so much I watch videos on languages I don’t use when intoxicated for fun.
Glad my dubiously professional grammar didn’t miss the target.
This is so good, I'll be sending this to anyone who asks about rust! Have you thought of part 2 for things like lifetimes and the ecosystem (crates,cargo,docs,test)?
Thank you! That's a great idea!
Thanks for the video and reference, it's immensely helpful to anyone who wants not to program in Rust but sees that working with programs written in Rust is the unavoidable future.
If you're going to have to do it, you might as well enjoy it!
(check my previous 3 videos to find out about the enjoyable features!)
@@NoBoilerplate Sure thing! I do like the language and the feel of it, and really enjoy Helix, nushell, Redox and whatnot, but it wouldn't benefit me to write in it more than in it would to write in Nim (which I'm already learning as I've found it most versatile on top of also being fast and safe). So yeah, I'll surely take pleasure in learning at least to read, understand and interface with Rust.
PSst, my favourite language-in-the-making's compiler is actually being written in Rust! Can you figure which one that's gonna be?
@@gimlam5909 Love Nim. My only concern is popularity, which in the software development world is a HUGE factor that I can't ignore. If I were to ignore popularity, I'd probably have written these vidoes about Haskell, which I love, but I can't hire for.
you are not like the others who puts link filled with adds, so u deserve to be subscribed..... thanks for the plugin and all the best for future
Thank you very much for you kind words. I don't know if I will do ads in the future, something on-topic in the middle of the video that is relevant to my audience perhaps. I suspect I could do more videos if I was sponsored - but I also find ads annoying! I'd love to know your opinion here, and thank you again.
Wonderful. I've mostly ignored rust as at work we are so c and c++ heavy. Seeing this made me think a lot of the Swift updates over the years and I can see how Swift is influenced by Rust. Thanks again for this video as it is exactly what I need.
Great stuff to try and absorb whilst multitasking.
This is absolutely amazing! Thank you for making this for everyone who needs it.
Thank you so much!
4:23 well except for wildcard imports ``use std::*;`` and the prelude items (including importing crates, ``std`` is available despite not declaring ``extern crate std;``)
I didn't understand everything completely, but its really nice to have an overall idea of what i should expect in my learning, journey. This type of content is as helpful as a detailed video, i hope you keep making these type of videos. Good job and thank you so much
My pleasure! Do check out the other videos my Rust series, there's lots of exciting features!
Very small correction : on most platform, long has 8 bytes, while int has 4 bytes in C and C++. Thus i32 refers to int or int32_t if you want to be really exact.
Other than that, excellent video.
> int has 4 bytes in C and C++
Also incorrect. int is defined to be at least 16-bit whereas long is defined to be at least 32-bit. So while int is indeed 4 bytes on a lot of platforms, the standard doesn't define it that way.
I could be wrong, but I don't think that's the case. In Java, you would be right, int is 4 bytes, long is 8 bytes.
In C/C++ though, long is 4 bytes, long long is 8 bytes, and int is determined by your architecture. If you're on a 32 bit computer, int is 32 bits aka 4 bytes. On a 64 bit computer, int is 64 bits aka 8 bytes. If you're somehow on a 8 bit computer, int is 8 bits aka 1 byte.
The architecture thing is also like isize/usize in Rust
@@zperk13 I don't think I can link anything here, but let me quote Wikipedia here:
> The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits.
You can also find these in the actual C standard here: 5.2.4.2.1 Sizes of integer types
@@zperk13 yes, this is the case on many embedded systems. There are lots of things like memory alignment and specialized instructions that are system compiler specific and make these subtle things like data type sizes a bit complex. It all comes down to the computer architecture.
Wow I feel better for getting this wrong - what complexity! You folks seem like you might know the answer to this: Is i64 faster than i32 on typical desktop 64-bit system? Another commenter said this. If so, maybe I should recommend i64s?
I got so interested in learning Rust because of your videos. going to develop Rust Backend service. thanks for inspiring me!
This is music to my ears! My entire goal is to nudge the dial of Rust's adoption. Good luck, and come and join us on Discord if you get stuck!
There's low demand for rust right now but I hope there will be. The language and tooling is excellent! I find that one can significantly cut down cloud computing and upkeep costs if they switch to rust. It's good for the environment as well. AWS has started to support more rust so I think we'll find more demand for rust soon.
Absolutely! I said similar things in my previous videos!
Most of the Big Tech companies are in the Rust Foundation, so I would expect It to grow significantly over the next few years. WebAssembly may prove another sweet spot for high-perf applications in the browser client.
I started learning Rust yesterday evening using "the book" and 2 minutes in this video I'm like "hey I know this! And that too!" Very cool
You got this!
You avoided the single most confusing part of Rust that is the most different from other languages: the borrow system and lifetime annotations
Literally the point I hit the roadblock, its like the language is constantly trying to throw away everything you see unless you explicitly state that you need to keep it.
The borrow system is literally just pointers/references from any other language + a few safety restrictions.
@@someonestolemyname that's literally what it does. are you perhaps a undergrad or hobbyist?
@@someonestolemyname what? That sounds like you gave up after 5-10 minutes of messing with references and move semantics, and never got used to it to see if it actually makes sense or not.
@@Anon.G and those safety restrictions means that you might end up in situations where you think it should work, because it would work in all other languages that you know, but it doesn't in Rust. This is even more confusing when you start composing your own types with structs and enums and they might contain (directly or indirectly) references and you need to be careful to place out all the lifetime annotations correctly. Furthermore, when you start including traits and heap allocations in to the mix then it can become a nightmare compared to other languages. Have you ever implemented a factory pattern in Rust? It took me over a day to figure out why my factories had to be singeltons for the borrow checker and lifetime checker to be happy.
Thanks!
welcome!
Did I just join a cult
You just witnessed truth
Talking nearly 10% of the video’s duration about how this video is boilerplate-free and straight to the point! That’s exactly my type of humor! 😂 Great video, though! 😊
Thanks! Do try my more recent rust videos too,
Rust is like the best parts of C++ and JS combined.
It's WAY more than that!
I tell people that Rust snuck the best parts of Lisp and Haskell, into the cool kids party in Lisp's clothing!
I'm a massive fan of getting straight to the point and getting rid of boilerplate, great video and style!
Thank you so much! Did you see my previous 3 rust videos? They're even FASTER!
3:16 Actually Javascript also has a block statement so the analogy with IIFE wasn't needed
Every day's a school day! Yes, another commenter pointed this out, that's great news. I already use `const`s exclusively in my js, it's wonderful to know they're even safer than I thought!
People have been praising Rust for years. After watching your video I finally want to try it. This language seems great
I would be very interested to get your take on Vlang and Zig, two languages that seem to be vying for a similar space as Rust. All three are meant to be extremely performant by ditching a Garbage Collector, but similarly avoid the gaping pitfalls of manual memory management.
Of course, in most situations, it's not really accurate to say "X language is the best, objectively better than Y language."
I personally lack the experience to do a full breakdown of what each language offers to the developer, which projects benefit the most from each language's best features, and so on.
oh COOL! I'd not read up on Vlang. Looks like a great little low-level language inspired by Go. HOWEVER it has a GC, which means I can already tell many things about the language:
- No embedded development
- Can't write linux modules
- Imperfect for hard realtime applications (music, flight control software, ETL pipelines)
- No borrow checker superpowers
I wonder who this is for? A Go developer wanting lower-level code? Then why does it also have a GC? Hmm. Cute though!
Zig I love - huge huge fan. It really helps you manage memory in a sane way, and the whole language has no surprises. But the kicker is you still must do it, and you might forget. Zig is certainly a better C, but they didn't try to push the envelope.
Rust's lifetime annotations and borrow checker are a FEATURE, not a burden. A rich type system is great, but if you add lifetimes to the types, you've enriched them in ways that don't just mean the compiler can manage memory for you - you can build your own types with complex temporal logic in.
One day I'll do a video on this XD
@@NoBoilerplate *Interesting!* I'd come across some performance benchmarks where Vlang would actually beat out Rust, and I found no mention of a GC, so I just kind of assumed there wasn't one. Impressive for them to reach that kind of performance with a GC, even if it's not really swinging for the same ball park.
And I'd be very interested to see that video 😁
@@chrs-wltrs I admit I didn't get further than the front page, where they mention it! Apparently there's a new mechanism that can statically free 90% of memory cases, leaving the last 10% for GC.
While that is terrific, I am left wondering how much time they're going to invest in an imperfect solution XD
As for performance, Rust benchmarks in 1.1x C's speed (Java and JS are 4, Ruby is 20 and Python is 80). So while I can believe it, rust is fast enough!
Very nice! I have a few coworkers that are trying to learn Rust after I have been praising it for a year. This will likely remove the "I don't have enough time to start it" excuse!
Amazing! Do give them the linked article that I based the video on - I know some people prefer reading (and copy and pasting!) rather than a video.
Also, make sure you've seen my previous 3 videos on Rust - they're about the incredible features of Rust that you can't get anywhere else!
My only question is what does the & prefix do in arguments and parameter types and when should I use it?
that means you're passing the argument by immutable reference. you should always do it if you don't want to change the value in place
Take a look at my previous video "Rust makes you feel like a Genius" for an explanation of the borrowing system. It's simple, but unfamiliar.
It means the function receives read-only access to the argument. It's called immutable reference. There's also &mut which takes write access. Without any prefix, the argument is taken by value, which means the function consumes it (unless the type is Copy, in which case a bitwise copy is passed in).
Thank you so much Sensei! You are a blessing!
Keep climbing the mountain, go train with Amos! fasterthanli.me
Great video ! but we need a part 2 : lifetimes, differences between String and str and traits
Coming up!
I'm happy to learn that my F# algorithms can be ported to Rust with just some minor syntax adjustments. Immutability by default, Ok/Error constructs, optional types, lazy expression evaluation, type inference, etc. And it's even possible to bring partial application and JSON type providers with 3rd-party packages, aka "crates"! From "I wonder what's the hype about" to "I should def try Rust out" in just 10 minutes.
oh you're gonna LOVE it. Yes, the `partial` crate is a vital part of my workflow! I think they snuck the best of haskell and the best of lisp into the cool kids party, wearing C's clothes!
tuples were weird for me because python tuples are immutable but rust tuples are mutable, but man tuples are powerful, its like a struct but without needing to make one
What's your most valuable use case for tuples?
Python calls structs Named Tuples - I think naming the elements is way more useful. I don't use tuples very often, not for big work any way!
@@NoBoilerplate I think so, too.
Go relies a lot on Tuples since it doesn't have enums.
After thinking more about it, I mainly use tuples when wrapping a type (New Type pattern afaik)
I usually use tuples for returning more than 1 thing
@@CunningBard Yeah, a pair of things is often OK for a tuple. In Rust, I find I'd rather name it and call it a Struct so that I know what KIND of paired data I'm working with. Javascript has made me afraid of anonymous blobs of data
I was confused by 3:30, where the "tail" of the declaration block is: "y + z". To the uninitiated, this almost looks like a function without a return type, and in other languages I've not seen this type of compound assignment. It took a moment of staring to realize the tail isn't a void addition that can be read by itself, but has to be resolved in your head then "returned" to the first line.
It might have helped to put an example print statement or comment showing "x" is now "3". Cheers.
Good point! This pattern comes from functional languages, I believe. Lisp, elm, haskell etc
Set the playback speed to 2x and it'd be 5 minutes instead of 10
These videos are for people like us 😂
learning rust in 5 minutes frfr
I've literally just watched it like that lol
This is probably one of the best introductions to Rust out there 👍
It's because I based it on the best blog introducing Rust :-D
I send people my previous video on rust as the best introduction I could make: ua-cam.com/video/IA4q0lzmyfM/v-deo.html&
3:04 - I wouldn't write "f -> void" if i were you. I'd use the proper type, "fn() or fn() -> ()" for consistency, and further explain that "() is a struct with no values. it is a unit struct, because it can only have one state; existing. it means void.".
Thank you! Errata pinned comment updated 👌
great video! im super amazed of this quality of videos being your first one, keep going and youll make it far! :D
Thank you so much!
I'm trying to create a programming language and I can't decide between using c++ or rust. I've tried doing some stuff in both, but it was a little difficult to do what I wanted with rust. No classes, can't assign references in structs without destroying the code with lifetimes and had many other problems while learning rust
Rust is certainly more difficult to learn, but it is WORTH IT! Have you watched my other videos on rust? In them I explain the unique features that you won't find anywhere else.
You're trying to create a programming language?
Yes, this is typical experience when starting to learn Rust, particularly for people coming from OOP. Rust is not the kind of language where you learn to translate syntax from language X, and you're good to go writing your code in whatever style you like. Rust has its own "coding paradigm", that's somewhere in between functional, OOP and imperative.
You tried to do some stuff in Rust, and it was difficult to do what you wanted, THE WAY YOU WANTED TO DO IT! That's the problem.
It took me about a year to learn the "Rust way of doing things". Unfortunately, I still can't fully explain what that is exactly. Especially not in a single youtube comment. People describe it as "becoming friends with the borrow checker", but never really describe how to get there.
@@NoBoilerplate Of course I did. That's why I decided to learn it :)
It is great because you can make no mistakes in your runtime because of rust if you use it the right way, it will have a difficult learning curve because of that, but like you say: it's worth it.
@@KohuGaly A year of learning is too extreme for me. I think I can learn it quicker, thanks to modern IDEs, but if it's worth in the long run, that's another question
I'm on Chapter 07 of The Book and this has been an almost perfect summary of what was taught.
All credit to Amos for the original article!
i was looking for this
thank you for making this video if possible please make a series of tutorial for rust for the people who already know some programming language
My pleasure! Read the original article too 😁
@@NoBoilerplate yes i will but i prefer video lectures over articles and documentation
In C/C++, the semicolon is not a mandatory white space, it is a statement of itself, which can be compiled into a NOP (no operand) instruction when needed, it is upto the compiler to do so or not due to compiler optimizations. Think of an empty for or while loops that do nothing, based on C/C++ language specifications, they require at least 1 statement, if none is needed, an empty statement can be used, a semicolon. 👍🏻
I usually default to u32. With what I code at least, I find that you actually very rarely encounter negative numbers
Seems reasonable to me, though some people might find the wrapping on negative behaviour surprising?
Thanks to Amos for writing this, and many thanks to you for representing it clearly and beautifuly..
It's my pleasure!
Wow, I never thought Rust has a lot of functional programming language features. I'm interested now
Right! Do look at my previous 3 videos for more astonishing features you'd never have imagined!
why not .. seems like everyone one youtube wants to go back to the 1960"s
@@robbietorkelsonn8509 It's becoming clear that the Object Orientation experiment has not been a wild success. Note that Reactjs and those like it use a functional reactive paradigm!
unbelievably well explained...to the point, no wafsofte wafsofte chat...you´re the dude ..thanks!
Thank you!
This is how tutorials should be; short, punchy, dense with useful information 💯
Thank you! All my videos are like this, here's another in the playlist if you've not seen it, I'd love to know what you think: ua-cam.com/video/sbVxq7nNtgo/v-deo.html
I also like the short and dense format, although I felt there were places where the examples were confusing for beginners and a bit more explanation would have been very beneficial. For example, I wish the video had explained what |c| meant.
Respect! Short and to the point
3:09 technically it returns the unit type, i.e. ()
Oh yes! Thank you for the correction!
I feel that rust is one of those languages where you need a knowledgeable mentor in the early days. I had a go at writing sha256sum in rust, and there was a lot of head-scratching and digging around to find out how to do things. Whereas in Python and C it was relatively straightforward. I say mentor because, when writing 'worked examples', you're guessing what the novice programmer wants to write. But rather, you need to start with a novice programmer who knows what they want to write, and then guide them as to how to write it in Rust.
You've got it exactly right. Back in 2020 I crashed out of learning Rust twice. First time due to multiple string types (haskell's biggest mistake made again, I thought to myself) and second due to lifetimes. At the time I had a great mentor (Shout-out to Alex!) who picked me up and helped me back on the path. Most people don't have this. They need the excitement of my hype videos to break through.
I will eventually run out of hype topics and move on to slightly more detail. But first, there's a few million developers I want to send to rustup.rs!
@@NoBoilerplate I've been learning rust recently, and chatgpt has been a great mentor. If I'm getting an error I can't make sense of, I can copy paste the offending piece of code and the error message, and like 80% of the time it tells me why it doesn't work. I still have to rely on traditional methods for the other 20%, but it greatly reduces the amount of head scratching I go through. It's been a bit of a challenge though, since nearly all of my experience is in C# and Python. I've never used a low level language before, so the learning the intricacies of low level + the intricacies of rust simultaneously has been challenging. I've come pretty far though!
@@sa1t938 oooh that's INTERESTING! I'm in deep with chatgpt, and I'm SUPER excited and scared for what 2023 is going to be like, with this tech revolutionising every single field!
I find writing C unbearable. Too low level, too much UB and too little abstraction facilities, unless you (ab)use the preprocessor. C++ is kind of OK but a real beast to tame...
1:55 c wont crash at runtime, it will just work with the value thats already under the address of the variable
Other people have said it's undefined behaviour - depending on implementation it may do as you say, or may crash? Either way, that sounds not great!
yes it is UB, but it wont ever crash on any impl
@@czarsonxd2093 oh! Thank you for that, I wasn't aware.
That's actually worse than if it just crashed. It means your C program may silently corrupt arbitrary memory. That's one of the worst kinds of bugs you could encounter.
@@KohuGaly Yeah, I think we're all in agreement there! I'm grateful for the correction though, I'll roll that into the ERRATA pinned comment.
On my CPU (i7 930), 64 bit numbers are significantly faster than 32 bit numbers. Surprised me a bit
Oh wow! I mean... All modern cpus are 64 bit, might they be faster for all? BENCHMARKS NEEDED!
It depends, some machine code generated by MSVC (and others) for x86 regarding i64 operations is inefficient and improperly considers microcode implementations
@@mariocamspam72 Interesting! something for users of the `windows` crate, on legacy hardware!
Thanks for this great video! I played around with rust before but haven't really looked into how the Result type and iterators work, now I want to create a small project somehow utilizing those :)
LOVE the result type - you can iterate through a result, imagining it is all working fine, and only handle the error right at the end, with a final .unwrap() (or equivalent). Do check my previous 3 videos for more explanation on this!
I liked the idea of rust but have no experience with it
I loved when I used functional features like match case and expression instead of return in Scala
This video makes so much sense, thank you. I like Rust now, just need to convince the boss typescript isn't the answer to everything
Typescript is certainly 100x better than plain Javascript! But yes, ideally you'd get some rust in.
Have you seen my previous videos? The "perfect" and "genius" videos might persuade your boss :-)
Your boss is right, if you're working with web development
Can somebody explain in a bit more detail what exactly the code at 2:34 is doing? Specifically, what is `slice.split_at(middle);` doing?
I might have invented that, though there is a doc.rust-lang.org/std/slice/struct.Split.html
I copied Amos's examples for the video here fasterthanli.me/articles/a-half-hour-to-learn-rust perhaps that particular line is psudocode?
I usually run videos on 1.5x speed. This was a mistake.
gotta go fast!
This is an amazing runthrough. I would love more tutorials liek this. So much value in 10 mins.
Coming from the world of python, rust is an entirely different way of doing things but I kinda like it 😁
* cherry picking time *
python: uses self notation, self is passed as an argument
rust: uses self notation, self is passed as an argument
python: has Self type (3.11)
rust: has Self type
python: has lambdas
rust: has lambdas
python: has match statement (3.10)
rust: has match expression
python: has async-await
rust: has async-await
python: supports custom event loops (things that execute async), unlike JS
rust: supports custom event loops
python: built-in C interface (as CPython is the most popular Python implementation)
rust: built-in C interface
python: has context management ( __ exit __ )
rust: has context management (Drop)
python: supports b"bytes" syntax
rust: supports b"bytes" syntax
python: native support for AST modification (ast module)
rust: native support for AST modification (procedural macros)
python: has _
rust: has _
@@-parrrate counterpoints:
a) I have dabbled in other languages for fun/uni but only really properly know python
b) I barely know anything about rust (have never actually coded in it myself, only heard good things from friends) (but cool to know it has all those things too)
c) it's a throw away comment on a yt video, I don't have the time or will to research everything I say 100%
d) (not really a counterpoint) you mean nitpicking not cherry picking I think? Nitpicking is pointing out little flaws in something, cherry picking is deliberately excluding points that don't fit your arguement. (Tbf you can do both I guess but saying you're cherry picking a) doesn't fit and b) implicitly weakens your arguement)
@@-parrrate It's still very valid to say that Rust is a different way of thinking lmao. I've used Python and JS a fair bit and even with TS, I've still not had to worry about the particulars of `str` vs `String` or borrowing or ownership at all. There's a reason why the "higher level" languages are often used more by beginners.
Rust and python make good choices about many things. I've used python professionally for 15 years, but it's time to move on. The GIL is terrible for python's concurrency, and it benchmarks 80x slower than rust in single threaded tests.
Python's ast does runtime modification, macros are compile time modification - a very different beast.
I've been writing python professionally for 15 years, and I think it's time for me to move on.
Rust was just familiar enough for me to learn, but it took me a while. That's why I'm making these videos, do watch the others!
That was a well-done overview for some of Rust's features.
All credit to Amos for the original article, there's about 50% more on it, link in the description. All of his articles are INCREDIBLE!
As a top tier impatient I am very displeased that 49 seconds into the video you haven't yet moved to the main topic!
This language takes many incredible things from OCaml.
Very good !
This video is not about Rust, the videogame... Oh well, I learnt stuff.
Surprise! I feel your pain the other way - it's very difficult to google for Rust language stuff without getting Rust game results XD
as a typescript dev, i finally grasped the purpose of generics from the feeling of freedom that i sensed from the voice at 5:43
too long should be 5min
Welcome to the rust community :) if you want a concise language may I suggest another
@@connormc711 I'm too impatient to do that
@@TegridyMadeGames you should practice patients I have found it too be more helpful than any tutorial
@@connormc711 can you summarize that sentence? Too long to read.
watch on 2x speed
halfway thorugh the book, rust is really amazing. so modern and fun, programmed a lot of stuff with it that i did to learn the classic languages 10 years ago, just for fun. it is so much fun to use
You're gonna have a great time!
That's a very useful video, although, I didn't understand most of it, lmao. At least now I will go to the rust book and read it all, because what you showed is peeking my interest a lot
I'm so pleased! Have you seen my previous videos? They give an overview of rust. Definitely try the book!
@@NoBoilerplate Yes, I watched every of your Rust related videos and really enjoyed them, that is why I got recommended this video. Thanks so much for making them btw
03:50 is that allowed by the Rust compiler? Or will it throw a warning?
Could you be more specific? Certainly, the variable 'feeling_lucky' is not defined in this snippet, so more context would be needed for this compile
@@NoBoilerplate I meant the multiple return statements in a function, certain C linters will warn about it and recommend to set a variable in the multiple branches and have it returned by one statement at the end of the function.
I'm just wondering if the Rust compiler would warn about the same. But I'm gonna try it out for myself 😊
@@themohmand oh! The Rust linter (clippy) has LOTS of help with using return statements, including redundant else blocks, unneeded return statements, and far far more!
Check out how friendly it is in this video: ua-cam.com/video/CJtvnepMVAU/v-deo.html
This feels like c++ and python had a weird baby and then JavaScript adopted it. The strange mixes of syntax make me uncomfortable lmao
Let me set the record straight: It's LISP and Haskell sneaking into the popular kids party wearing C's coat.
Try out ua-cam.com/video/4dvf6kM70qM/v-deo.html next and let me know what you think!
@@NoBoilerplate sorry, not raised by JavaScript, raised by wolves lol
you made me fall in love with rust within the first 5 mins
The same thing happened to me when I read the article this video is based on, from fasterthanli.me!
Continue your journey of discovery here, I've got a short rust intro playlist, not just talking about the syntax: ua-cam.com/video/oY0XwMOSzq4/v-deo.html
On one hand, the compiler being this pedantic over almost all the things is fantastic since most "throw away code" is something you actually NEED to throw away and some crude prototyping can happen during compile time instead of runtime.
On the other hand, I think you can make some specialized logic based reprap that creates stubs and fake integrations before you move onto creating the "official integration" in some other language that maybe less concerned with some forms of errors that _may_ be caught in Rust before deployment. At least you won't have to deal with the type signatures made famous in that "American Psycho" business card parody of Rust functions from theSTEMgamer XD
Could you explain a little more?
If you can create a lambda calculus in Prolog, you can also create dependent types in this language.
maybe_fopen(_, _, -1, invalidFile(E)) :-
E = 'Could not open file'.
maybe_fopen(PATH, FLAGS, FD, RESULT) :-
((string(PATH), string(FLAGS)) ->
(integer(FD) ->
RESULT = validFile([PATH, FLAGS, FD]);
RESULT = invalidFopenReturn('File descriptor must be integer != -1'));
RESULT = invalidFopenArgs('Path and Flags must be strings')).
When you query for the result of this call like:
?- maybe_fopen("/tmp/foobar", 36, -1, R), print(R).
You now get ALL the possible ways this specific function call with these specific arguments can fail, including the -1 file descriptor AND the invalid argument types.
I'd say Prolog and similar constraint solvers in the logic programming space are one of the better tools for high level blueprint coding that can also be interactive since prolog can import and run these scripts inside of a REPL. This might be a great starter for automatically generated tests with functions/predicates in this kind of dependently typed domain, since it's cheaper to change the code up front at design time rather than review/production release time.
Jarble's transpiler on github and Warren's abstract prolog machine would be great study materials if you're more interested in the topic.
@@SimGunther That is very cool! Thank you
This is an excellent revise material! Thanks!
Do check the source material, fasterthanli.me is fantastic. Also I bookmarked this today learning-rust.github.io/docs/a1.why_rust.html
@@NoBoilerplate Yes. Already bookmarked it! Thanks. :)
How do you not have more subscribers?
You're too kind! But I'm not sure i deserve the ones I have! It's incredible!
@@NoBoilerplate between these videos and Lost Terminal, allow me to politely but strongly disagree, you deserve all these subscribers and more!
Humility is a great thing but don't down play your good work unnecessarily either 😊😊
@@NoBoilerplate
Well, you seem really quite skilled at condensing complicated topics down to understandable, short videos. The closest example I can think of would be Fireship or (, though it’s not on the same topic,) CGP Grey. For reference, they have 1,4M and 5,43M subscribers respectively.
Until you have at least a hundred thousand, I’d consider you underrated.
Man, your videos are so good.
Thank you so much! They're not really anything special, the trick is I PRACTICE them a lot. What's a few hours of practice for me, to thousands of hours of everyone's time? Seems rude not to!
The Sequel: Tauri in Ten Minutes?
The native app framework? Maybe! Have you tried it?
@@NoBoilerplate Never tried it, but I plan to soon. It looks awesome. It's like Electron but using much lighter weight Rust for backend, glue logic, and a browser-like front end interface.
It claims to have the ability to glue other runtimes into the same binary, like Node.js, Julia, and Python, to mix and match polyglot tech stacks relatively easily.
I've been intermittently looking into whether I can use it to have Python & Pyscript do the front end UI stuff, with Rust in the back end to handle all the heavy data crunching and OS interactions, while sidestepping the staggering binary size & memory footprint bloat that comes with using chrome/electron. It seems possible.
As soon as I can make the time I really want to make a network mapping tool, because Visio is a crime against UX design, and it's looking more and more like Tauri would be the best way to do native application development.
Be nice to hear you talk about closures... I love a nice closure.
I'm game! What would you want to hear?
@@NoBoilerplate I'm not sure... I'm still just "Rust curious"... I've compiled once and had a fight with the borrow checker.... I know closures from JS and I say to people who like to use JS like it has classes "no... closures are beautiful".... I'm currently doing some Kotlin (more because I need an Android app than any specific desire for Kotlin) and I'm looking forward to my first closure there. I've got an embedded project on the horizon that would be nice to do in Rust..... but I'm still only "Rust curious" at the moment... I wonder if Antartica speaks Rust?
@@edgeeffect Rust has both first class functions and higher-kinded functions, you'll find just the functionality you want!
Nice LT reference! In my mind, though I don't mention it too much in the show, AIs are written in LISP, and speak native Lojban (pronounceable mathematics, look it up!)
I feel like i stumbled upon a cult
Welcome to the cargo cult! Let me know what you think of this follow-up video ua-cam.com/video/oY0XwMOSzq4/v-deo.html