ERRATA - Example at 5:51 is incorrect: Missing mut on line 1. Lines 6 and 7 are legal and compile. You need to take a mut ref to neuromancer in another var to cause a compile error. - Also the 2nd editor is molly, but in line 7 it's dave. - Rust can only deal with out of bound errors at build time when you are dealing with constant values. Unfortunately, most of the time, these errors happen in cases more complex that the compiler is not able to detect at compilation time. (though runtime errors are still better than python, eg the len is 3 but the index is 6) - 7:09, the error says the value `vec` was moved, when the variable is actually called `users` in the code. - 5:00 `name` is a reference, `&str`, which implements the `Copy` trait. So it is implicitly cloned and not moved. I should have to used a `String` in line 1. - 9:22 "IS EQUIVILANT TO" should say "IS EQUIVALENT TO"
@NoC4k32 жыл бұрын
While we're at it: in line 4 you declare the 2.nd editor as molly, bit in line 7 it's dave. (6:26)
@NoBoilerplate2 жыл бұрын
@@NoC4k3 Thank you!
@henkoglobin2 жыл бұрын
@@NoBoilerplate At 7:09, the error says the value `vec` was moved, when the variable is actually called `users` in the code.
@NoBoilerplate2 жыл бұрын
@@henkoglobin So it does! Thank you very much, I renamed `vec` to `users` to make it more understandable. My future videos are much better at catching this kind of error with compiled mardown source. Thank you!
@henkoglobin2 жыл бұрын
Oh and while we're at it... at 09:43, it says 'equivilant' instead of 'equivalent' :D Btw, very impressed with your videos! I only found them yesterday, but they're giving an amazing intro to Rust and I love every minute of it!
@theRealPermagreen2 жыл бұрын
The perfect recipe for making anyone feel like a genius is to give them problems to solve, constraints they have to work within, and a good selections of tools. Puzzle games have been following this formula for years, but Rust also does this exceedingly well.
@NoBoilerplate2 жыл бұрын
I can't tell if you're complementing Rust or hate puzzle games!
@rallokkcaz2 жыл бұрын
@@NoBoilerplate I think it's both but goddamn does it work!
@astral67492 жыл бұрын
Remember not to include unintuitive behaviors.
@NoBoilerplate2 жыл бұрын
@@rallokkcaz No puzzle game ever let me write Linux kernel modules, so there has to be more to it than that XD
@theRealPermagreen2 жыл бұрын
@@NoBoilerplate Admittedly, most puzzle games I know don't give you tools which are Turing complete and a lot of them devolve more into trying to figure out which specific solution the devs had in mind rather than using logic to reason things out, but I think my point still stands
@Yogii00002 жыл бұрын
Hi. Rust developer here. Your compile time error on an out of bounds array access is only possible because that is a static array. It's a very cherry picked example as this scenario is rather rare. With Vec you would also get a stack trace at runtime if you were not using .get(n) and checking the Option. While rusts error messages are great and even its stack traces are very clean it is worth being careful to set correct expectations. It is not magic. Furthermore language communities (and the entire discipline of software development as a whole) has a rampant evangelism problem. It's great to be enthused but be enthused with caution please.
@NoBoilerplate2 жыл бұрын
Ah yes! Thank you very much for the correction! What I should have said, is that even at runtime, rust's errors are better. For example: vec!("cat", "dog", "mouse")[6] > index out of bounds: the len is 3 but the index is 6
@harshmudhar962 жыл бұрын
Also.. It's totally a fair comparison on static analysis when one of the languages is javascript, lol.
@mr.mirror12132 жыл бұрын
@@harshmudhar96 💀💀💀
@franciscomacedo59842 жыл бұрын
Ah evangelism indeed, the fantastic world of Software as a Religion (SaaR)
@harshmudhar962 жыл бұрын
@@PefectPiePlace2 ok ayaka.
@scheimong2 жыл бұрын
This is exactly how I felt when I started writing rust a year ago. Coming from Java, the programming experience I was accustomed to was that the first time I run my project (or the first time after a big commit), there is a 95% chance that my code will immediately crash due to some obvious oversight. With rust it's the complete opposite - if the linter (rust-analyser) doesn't complain, there is 95% chance that my code WILL run. It is an absolutely refreshing feeling that no other language has ever allowed me to experience.
@NoBoilerplate2 жыл бұрын
Isn't it joyful!
@brunocabral882 жыл бұрын
I guess you’re not testing your code enough (if at all) then. It’s nice to have the compiler warn us about the bad things that may happen, but it will never replace the good old testing..
@1SquidBoy2 жыл бұрын
@FichDich InDemArsch you can do better than that
@NoBoilerplate2 жыл бұрын
@@1SquidBoy I blocked him, sorry for the trouble
@NoBoilerplate2 жыл бұрын
@@brunocabral88 Quite right: Testing is never going away, and is indeed very needed. In my experience, Rust lets you test what actually matters. The richer you type system, the more the compiler can prove your code, and the less low-level unit testing needs to happen, and you can focus on testing behaviour. It's such a relief!
@adileturaimov59522 жыл бұрын
You're like Bob Ross of programming: "Just look at this little happy error" 😂
@NoBoilerplate2 жыл бұрын
Thank you! I think of myself more as Mr Rogers "I'm not very good at drawing, but it doesn't matter"
@adileturaimov59522 жыл бұрын
@@NoBoilerplate Ahah, exactly!
@Nishandh_Mayiladan2 жыл бұрын
LOL
@Hwyadylaw2 жыл бұрын
I started my first Rust project the other day, and while I still have some things to learn about the language, but between the documentation, error messages, cargo, rich type system, Ferris the crab, borrow checker among other features, it feels like a dream.
@NoBoilerplate2 жыл бұрын
All this, and it's popular, too! What a gift!
@raffimolero642 жыл бұрын
the crab has to be the best language feature. oh you mean the crab is only a fan mascot? shut up. the crab is a feature.
@NoBoilerplate2 жыл бұрын
@@raffimolero64 🦀
@n0xter952 жыл бұрын
I don't know anything about rust, I am a web developer and I work with - you guessed - JavaScript on a daily basis. I am amazed at how you explained everything so fluently and slowly. As a result, I could tell what was happening at minute 7:00, without having ever touched any rust. You made me feel like trying Rust. I believe I will fall in love with it. Please don't stop posting
@NoBoilerplate2 жыл бұрын
THIS is what it's all about. Thank you friend for commenting. I'm also a web developer, and I want to build websites in Rust! By the way, you can get all of this on the frontend because of native webassembly, check out yew.rs (boring website, excellent framework)
@n0xter952 жыл бұрын
@@NoBoilerplate Thanks! I wish you were my school professor with the way you explain, learning like this is a whole new experience! Also, the website is very pleasing and eye-catching. I like it. I will have a look at everything, but first I'll be sure to check out some Rust material to get the hang of it. Keep it up!
@NoBoilerplate2 жыл бұрын
@@n0xter95 You're too kind! My next video will be on the magic of macros and why you should want them
@clonkex2 жыл бұрын
If you don't already, use typescript. Once you get over the initial hurdles of getting it to compile and ensuring you have type definitions everywhere it makes JavaScript VASTLY more usable, fun, easy and reliable. I still prefer C# but TypeScript is a close second
@NoBoilerplate2 жыл бұрын
@@clonkex I agree with David here - Javascript is a necessary evil of our work as developers, and TS SIGNIFICANTLY tames it! However, for my next frontend project I'm going to be trying out Yew yew.rs !
@microcolonel2 жыл бұрын
I've been writing lots of rust over the last few weeks, having dabbled and written a few things about a year earlier. It definitely gives that "this is gonna work" feeling; and furthermore if you actually pay attention to what the compiler is telling you, you often stop making the mistakes altogether.
@severinweigold91252 жыл бұрын
Your example with the „neuromancer“ manuscript will not compile, but not for the reason you stated. In order for line 6 to compile, your neuromancer variable needs to be declared as mutable on the first line. If line 6 compiles, line 7 will also compile, since the variable is only mutably borrowed until the „edit“ function returns. In order for it to not compile, you would need to store a mutable reference to the „neuromancer“ variable before calling the „edit“ function.
@NoBoilerplate2 жыл бұрын
Oh no! You're quite right, thank you for spotting this error. I will add it to the ERRATA section in the video description. I will compile my examples next time!
@boiimcfacto23642 жыл бұрын
@@NoBoilerplate I doubt a language can make you feel like a genius when the comments' section has to point out the error lol. JK, loved the video!
@jens63982 жыл бұрын
"A language that stops you making mistakes" - Followed by a subtle mistake... Not exactly advertising Rust here.
@remrevo39442 жыл бұрын
@@jens6398 Well, it would not compile, that's dramatically different then when it failed at runtime.
@mattshnoop2 жыл бұрын
@@jens6398 except when he makes this "subtle mistake", the compiler will give him a very pretty error message explaining exactly what's wrong… which was the point of the whole first five minutes of the video lol
@BlunderMunchkin2 жыл бұрын
I guarantee that I will still sometimes feel like an idiot regardless of what language I'm programming in.
@NoBoilerplate2 жыл бұрын
Respect. Nothing wrong with being humble
@mostefajakboub2847 Жыл бұрын
your comment match perfectly with your profile picture
@maheshkanojiya4858Ай бұрын
We are same bro
@Haiderali-qd1jy2 жыл бұрын
Last week I subscribed, happy to see another rust video. Liked it
@NoBoilerplate2 жыл бұрын
Thank you! I hope you like it!
@darkchoclate2 жыл бұрын
Python - "list index out of range" He - "Python would not tell me what's wrong here" Python - "Am i a joke to you?"
@NoBoilerplate2 жыл бұрын
Sure, but where, what index was out of range? As I said in the video. However Python's kind of a joke to me these days. Have you ever tried explaining virtualenvs to someone? They don't reply straight away and give you this LOOK O.o
@darkchoclate2 жыл бұрын
@@NoBoilerplate I totally get your point... That Rust is better in showing bugs... It tells you exactly where it is, and what to do... I dont hate it, nither do i care about it... I agree that c and c++ dont have any usefull error management, where rust is clearly better... JS is joke at this point, i dont get why it has not been replaced, perhaps because of it wide spread use... But python's error management, i think is sufficient, If you are a developer, You dont need to be told what to do, you are capable of that, you just need to know what's wrong and where is wrong, that python does... And rust and python, both have it's own use, python is built to be easy to explain, yet beautiful to write, where rust is built to be safe, yet provide deep level control, so there is no competition here... and talking about venv, i think you need to explain better to user... Explain like this... "We have this python interpreter with it's library, now when we make apps, we download many library. Most apps we make will have different dependency, so there is high chance we will run into conflict with one dependency with other. On the other hand if we have a huge amount of dependency, python interpreter will have hard time finding what to import. so instead we keep the original interpreter where it is, and make a copy of this interpreter in our project directory, and use the copy instead, to store our dependency. So every app let have their own dependency in its own copy of python so no conflict happens..."
@NoBoilerplate2 жыл бұрын
@@darkchoclate "and so we rewrite the PYTHONPATH because the interpreter assumes everything is installed globally, and it has no concept of a project". Don't get me STARTED on setup.py deployments. Poetry is the best of the bunch, imo, but it's wild behind the scenes. As to the magic of Rust errors. You have nothing to compare this with in Python, and I didn't show it very well in this video (more to come). The trick is that after you've built the valid states of your program in the rich type hierarchy (or borrowed the aws or windows crates to do the work for you) the errors become not just primitive "array length x" or "invalid character at line y", but can deeply understand your system, and you can get errors like "this function uses the billing address when it should be the logged-in user's home address" (obviously, not in so many words). Think of it like database relations - rules that can't be broken, but at high-level in your code. I'm going to do a video on this soon, so stay tuned for more! If you haven't yet written much Rust, this might be an alien concept to you, because python doesn't have a rich type system. Have you tried Haskell? I learned that to become a better python developer - it's got a rich type system like Rust (a bit better actually). The problem we all face, and I hope you don't think I'm talking down to you, is called The Blub Paradox www.paulgraham.com/avg.html
@TristramOaten2 жыл бұрын
@SomeName SomeOtherName OH GODS I'M GETTING PTSD
@NoBoilerplate2 жыл бұрын
@SomeName SomeOtherName Your life doesn't have to be this way, it's not a 'generic' problem: it's only a problem with old "global install assumed" package management tools. The current way we do things is to isolate applications from each other: Docker is a great way of doing that with the current apt/pip/gem/npm infrastructure, but you don't need it in modern languages like Rust, where the package manager (cargo) keeps this all isolated for you. Rust even has hardly any system requirements - you don't even need libpostgres/libpq because they have been rewritten in native Rust, and then high-level interfaces built upon! This is the topic of my next talk, I hope to explain it better than in a short comment.
@Hobbitstomper2 жыл бұрын
The only thing missing is for the ecosystem to catch on. We still have a massive lack of popular libraries/packages and frameworks in comparison with C++ and Java. While rust is easier for developers to write code, the lack of libraries and frameworks is a tough pill to swallow if you want to use rust for a bigger commercial product. It becomes so time consuming to develop certain functions from scratch. And if there is library or framework alternative available for rust, the lack of documentation, tutorials or community answers can be very frustrating. I really hope that within the next 5-10 years the ecosystem catches on. Then again, being in such early days is a big opportunity to help shape the future of rust.
@meamzcs2 жыл бұрын
Since you can call into C code almost without losing any performance, a lot of bindings to C libraries exist.
@NoBoilerplate2 жыл бұрын
While that is true, let's keep perspective. Crates.io has the same number of packages as NPM did in 2012. There's a lot to do, but I remember how much production JS I wrote in 2012 - I think there's certainly enough popularity to get cracking! In terms of documentation, I must strongly disagree, I find Rust crates' documentation to be the best I've ever seen. Perhaps the built-in documentation system encourages this behaviour? But in general, I agree with your statement: You CAN and SHOULD write production Rust in 2022, and there are plenty of core packages to support you: AWS sdk, windows sdk, world-class serialisation (such as json) and async. But while all of these exist, there will be more plumbing to do than with a more mature language ecosystem, so greater experience will be required.
@RyanRussonDev2 жыл бұрын
I can see how, coming from JavaScript, Rust would seem miraculous, but we've had strongly-typed, compiled languages, and compiler linting for quite some time. A comparison of Rust's advantages over Java, C#, C++, etc. would be a lot more useful.
@NoBoilerplate2 жыл бұрын
This is a deliberate omission. You can find hundreds of videos comparing rust to C and friends. If you're coming from C, the benefits are obvious, and even more importantly, you understand them. Tell a python developer that they don't have to manage memory and they'll be all O.o
@shlokbhakta2893 Жыл бұрын
@@NoBoilerplateO.o
@dorjegilfillan2 жыл бұрын
I don't know if rust would have ever entered my radar if not for your video, started writing rust a few weeks ago and have been loving it since.
@NoBoilerplate2 жыл бұрын
That is SO good to hear, my entire motivation with these videos is to shine a light onto this incredible language that is just WAITING for us to change the world with!
@alejandrocelery30917 ай бұрын
Your video-making style is stellar. I don't know Rust, and all snippets I read made me think "geez, why did they do this or that with the syntax?". But after "rust for the impatient" and this one I'm really interested in learning more. Superb, kudos!
@ItzKernel2 жыл бұрын
and this is why you can easily get addicted to programming in rust
@NoBoilerplate2 жыл бұрын
That's it! Very satisfying 😁
@PCB3892 жыл бұрын
Bro I just made a Hello World example and feel like Linus 😎 After that I just want to finish my work and go do some Rust programming all day
@nexus4dev2 жыл бұрын
:/ Rust eventually will Die one day and no one will use it, but we have A LONG time before it will happen!
@ItzKernel2 жыл бұрын
well, everything will die eventually
@PCB3892 жыл бұрын
Is better to rust out than wear out. -Some old guy
@thearyanahmed2 жыл бұрын
Never thought I would watch rust video as bedtime story 😂 Nice voice and storytelling sir! Btw, rust compiler sometimes seems like a mini AI.
@runtimejpp2 жыл бұрын
best idea thanks
@NoBoilerplate2 жыл бұрын
If you want me to ACTUALLY tell you a bedtime story, I produce a Hopepunk podcast called Lost Terminal narrated by a mini AI! kzbin.info/www/bejne/pmTFdXhvoNitg8U
@hezuikn2 жыл бұрын
@@NoBoilerplate i cant wait for season 2!!
@NoBoilerplate2 жыл бұрын
@@hezuikn I have great news! There's 8 seasons! I had unintentionally named them badly so they were difficult to find on youtube. I've fixed the playlist names, here's season 2 kzbin.info/www/bejne/rnOyhampo7Vsi8k
@NoBoilerplate2 жыл бұрын
@@runtimejpp Start here kzbin.info/www/bejne/pmTFdXhvoNitg8U
@Tanimodoli2 жыл бұрын
1:41 JavaScript's Array has variable length while Rust's Array has fixed length. If you want to use a "fixed length" Array in TypeScript, you must use Turple annotation or as const. The TS will report an out-of-index error at compile time as Rust does.
@NoBoilerplate2 жыл бұрын
Quite right, my example was not apples to apples. I should have illustrated rust's good errors with a better one, apologies!
@martinslns2 жыл бұрын
still havent written any line of Rust and I'm already loving the "ownership" concept
@themichaelw2 жыл бұрын
2:50 It's worth noting that *most* Rust errors are compile-time errors. Some cannot feasibly be checked at compile time (eg. accessing values within a while loop) and will generate a runtime errors. let array: [i32; 10] = [0; 10]; for i in 1..11 { println!("{}", array[i]); } this will compile just fine, although it will inevitably cause a runtime error.
@NoBoilerplate2 жыл бұрын
Yes indeed, I should have compared like-for-like. HOWEVER the runtime errors are still better than python's errors (rust tells you WHERE on the line the error happened)
@bourehimyoussef111 Жыл бұрын
I never thought I would be on the verge of tears in front of a programming video.
@NoBoilerplate Жыл бұрын
Imagine what you will be like if I TRIED to make you cry, as I do in my story, Lost Terminal! Would love to know what you think: kzbin.info/www/bejne/pmTFdXhvoNitg8U
@OwO-.2 жыл бұрын
Rust is such a cool language. I've worked with a lot before, but Rust is by far my favorite. Also, another very cool aspect about Rust is because it's so safe, you can use code assistants like Copilot with confidence everywhere. Using it in other languages like JS is fine after checking if it doesn't crash, but the Rust compiler immediately tells me if it's wrong. Great video btw!
@NoBoilerplate2 жыл бұрын
GREAT point! I hadn't considered that. It's like an extension of how comfortable I would be accepting Rust PRs: I have very high confidence that if the code compiles, I only have to focus on the logic
@leo8482 жыл бұрын
Copilot still generates faulty code that compiles in Rust. One example of this is ranges: it seems to not understand that a..b means exclusive and a..=b inclusive in any functional-style code.
@himboslice_2 жыл бұрын
so many views in such a short time had me questioning whether or not these vids had botted views lol. great content, glad the algo picked it up :)
@NoBoilerplate2 жыл бұрын
I can't believe it either, people love rust!
@eboatwright_2 жыл бұрын
"You have to sit there and think about what caused your error. Because JavaScript is _certainly_ not going to tell you" SO TRUE!
@NoBoilerplate2 жыл бұрын
yep!
@stdprocedure2 жыл бұрын
I came from Java, and initially, I didn't like Rust too much. But, sometimes, I felt that my code was always missing something. For example, immutability, null checking, optimization, and even manual memory optimization. Rust is the best programming language, because it's the language that has less "stupidity", your code can do exactly what you want to do, without worrying if some random state can cause a different behavior in your program. Rust doesn't have nulls, Rust has memory safety, which is REALLY COOL, because understanding your memory, you understand the relationship between other data. Everything I wanted in Java, is in Rust. All my dreams about making the perfect code, are here. Rust makes you feel like a genius, because other program languages, makes you feel stupid.
@NoBoilerplate2 жыл бұрын
You've captured my feelings too! This is why I started this video series!
@nderimtopalli30272 жыл бұрын
I am a Javascript developer. The borrow checker blew my mind. Never seen anything like this. Seems it is time to give a look at Rust. Thanks for the video. Subscribed.
@NoBoilerplate2 жыл бұрын
Always good to learn more languages, especially if they teach you something useful! Keep excited about the borrow checker, there's some tough new concepts for you to learn at the start, but it is WORTH IT. I started here, you should too doc.rust-lang.org/stable/book/
@spicynoodle74192 жыл бұрын
Debugging JS (especially React) is terrible
@friendlybear59242 жыл бұрын
Another very nice video. you also included some funny references and metaphores. I can't imagine how many hours you spent writing the script. Thank you for your great efforts to enrich our knowledge on Rust!
@NoBoilerplate2 жыл бұрын
You're too kind! Check out fasterthanli.me for really great in-depth rust tutorials from someone who actually knows rust XD
@jacksonarnold272 жыл бұрын
Just need to say that the example/analogy at 5:10 is so fantastic. It instantly stuck and made sense; totally helped me understand a concept that was still a little bit nebulous to me. Love these videos and they literally were the first thing that let me understand what Rust actually is and why people love it so much. Like I knew about the compiler being amazing but not much else. Literally refactoring one of my projects in Rust now
@NoBoilerplate2 жыл бұрын
I'm so pleased! The code in the Library example is a bit wobbly, see the ERRATA pinned comment for some mistakes I made there - HOWEVER the idea of loaning a book as an immutable borrow is CORRECT. I'll probably re-visit it in a future video with better code!
@ankk982 жыл бұрын
Impressed by the design of rust lang and the explanation of this guy.
@NoBoilerplate2 жыл бұрын
Thank you very much! Have you seen my first video, "Rust: Your code can be perfect"? More details there! I'm planning a whole series in the same style :-)
@udianilbey2 жыл бұрын
Two very nice quotes from this video: "This solved the most difficult problem the hard way, not cheating with the garbage collector or leaving it up to the developer". "If you make a compiler that understands your program's memory exhaustively then you have made a compiler that understands your code exhaustively".
@NoBoilerplate2 жыл бұрын
Thank you! The first idea is very important. You can make memory easy, but then you lose out on the power!
@abhishek.rathore2 жыл бұрын
Great video dude. Been learning Rust and I have been loving it since. Its awesome. Just like your content. Keep it up.
@NoBoilerplate2 жыл бұрын
Thank you so much, I really appreciate your words!
@elliott6142 жыл бұрын
I always wanted to chuck my computer off the balcony bc of that pesky borrow checker on my PL theory class projects (where we were doing things that were absolutely stupidly hard to do in Rust). But what's cool is almost every single time, once it compiled it worked perfectly
@NoBoilerplate2 жыл бұрын
This is exactly it! You will eventually get a feel for writing reasonably correct rust (at least, that's what I'm hoping for lol) and after this learning curve, you have a whole career of rock solid correct code to look forward to!
@zeenix1472 жыл бұрын
Great video!! One small thing: the “users” variable doesn’t need to be declared mut, even if the “send” method it’s passed to, takes mut because we’re giving up its ownership to that method.
@NoBoilerplate2 жыл бұрын
Good point! I really need to consult with either a rust expert or the compiler for the next video!
@porky11182 жыл бұрын
I like how rust turned a weakness into a strength. The main reason, why these error messages were added, was the complicated borrow checker, so they needed a way to make it more accessible. And once they had that system, they just used it for everything. At least that's how I think, it was.
@NoBoilerplate2 жыл бұрын
Right! That's a great way of looking at it
@cerulity32k Жыл бұрын
Every variable has one thing, and every thing has one variable. Such a simple rule extends so far.
@stef4oben882 жыл бұрын
The very first time i tried rust long ago, I was very impressed with the error messages, since i've never seen such good error messages. Rust has a lot of really good and interesting ideas. I think the only big issue is that it can take quite a while to get used to it.
@NoBoilerplate2 жыл бұрын
Totally agree, it's a STEEP learning curve (I mean, not compared to C or haskell) get back into it with this blog, if you've not seen it: fasterthanli.me/articles/a-half-hour-to-learn-rust
@violetsweet16603 ай бұрын
I have just started learning Rust after Python, and despite the numerous errors that caused my first program (first not directly sourced from the Rust book, anyway) to not compile, it was extremely satisfying to be able to whittle them down one by one using only the compiler's error messages. They are so clear, and the suggestions are so useful. This really minimizes the amount of pain I suffer from being unfamiliar with the syntax because the compiler just...tells me what I should be doing instead. Also, cargo is just great, and makes me not have to worry about any sort of Python-style Package Dependency Nightmare. It tentatively feels like Rust is a language that prevents one from being lazy up front so as to save one from more annoying work in the long run.
@derrick35342 жыл бұрын
Wouldn't it be nice if Morgan Freeman narrated borrower checkers?
@NoBoilerplate2 жыл бұрын
Morgan Freeman wishes he sounded like me ;-) /j
@the_real_briel2 жыл бұрын
Thank you so much for this juicy video! You deserve more views! You explained everything so succinctly without dumbing anything down. I was even able to show my girlfriend who is learning javascript this video on why javascript is whacky and she understood every word and every example! Not an easy feat! Thanks again, I hope to see more great videos like this in the future!
@NoBoilerplate2 жыл бұрын
Thank you! More on the way!
@cocacodes2 жыл бұрын
I am curious on how the Option and Result can be abstracted away. Wouldn't they have to store another byte to show if it None or Some?
@ericshimizukarbstein68852 жыл бұрын
That depends on the concrete type of T, in general, yes, it has to store a extra byte, but for other types, like any reference to any type, the non null raw pointer types, the File type, and some others receive an compiler handled optimization where the None value is equivalent of a invalid value of those types. Option of References and non null raw pointer get optimized to NULL value on the None case. In the case of Option of File, the internal value of file_descriptor are set to -1 on UNIX (and on Windows an equivalent invalid value). Result cannot get the same amount of this kind of optimization because of the error type it needs to hold.
@cerulity32k Жыл бұрын
Yes, there is a discriminant byte. However, in the case of Option, a null reference is treated as None, because references cannot be null, so the discriminant byte isn't needed.
@vaidphysics Жыл бұрын
This whole notion of "data ownership" and that a variable ceases to exist the moment you assign it to another variable is something completely new to me. And I've worked with C++, Python and several other languages for decades now. This is one reason I look to learning Rust - to discover these "design patterns" (if that's the right term) which I've never encountered in other languages.
@NoBoilerplate Жыл бұрын
My background is also very similar to yours (without the C++), Rust's refusal to repeat the same mistakes as other languages makes it VERY interesting to me! My understanding is that this pattern is similar to RAII, in C, except it's enforced at the compiler level, so you don't have to trust that your contributors have snuck in memory mistakes. I have a short playlist for people wanting to get up to speed with learning Rust and it's exciting features, if you're interested: kzbin.info/www/bejne/pYqTiaqDhLitp5Y
@NiDeCo2 жыл бұрын
As a full-time Haskeller, everything in this video sounds like a no-brainer 🙃 But I do appreciate Rust's popularity convincing more programmers to write code the smart way. 👍
@NoBoilerplate2 жыл бұрын
This exactly this. I spent a lot of time in 2020 trying to find what the most perfect real-world language is, and my top 3 were Rust, Go, and Haskell. Haskell would have won, but I can't hire for it. I'm so excited by Rust because it's like Haskell snuck into the cool kids party wearing C's jacket. (and then won every game using Lisp's macro magic)
@godofbiscuitssf2 жыл бұрын
"the" smart way.
@NiDeCo2 жыл бұрын
@@NoBoilerplate That, and I guess Haskell's errors are still pretty bad (since there's been so little focus on them), so I understand why you'd put Rust above it. Though I have to say, I'm loving the acceleration that's happening in the Haskell ecosystem right now. We're getting more and more momentum in getting rid of legacy issues, more effort and money into getting everything up to standard, etc. So I'm really hyped for what's gonna happen in the coming years, and also hope Rust will keep steaming ahead ♥
@NoBoilerplate2 жыл бұрын
@@godofbiscuitssf Rich type system + functional programming is the right way. It's even snuck into javascript through React!
@godofbiscuitssf2 жыл бұрын
@@NoBoilerplate Not for everyone, and certainly not for every context of programming.
@pilotashish2 жыл бұрын
what a video. Enjoyed every second of it. The narration, to-the-point structure is so good. If only every video would be like this.
@NoBoilerplate2 жыл бұрын
Thank you! All of my videos will be like this! (Did you see my previous rust video?)
@pilotashish2 жыл бұрын
@@NoBoilerplate yes really like your style. Subscribed
@NoBoilerplate2 жыл бұрын
@@pilotashish I'm writing the next one now!
@leddoo2 жыл бұрын
look, i get it, everyone here is very excited about rust, and that’s amazing! but there are also some misleading and very wrong claims here: rust’s type system doesn’t help you write *correct* code. in fact it is *very* bad at that (like almost every other language too). rust does help you write type and memory safe code, and prevents unexpected errors. but you can’t express domain specific constraints, like index < len, this array is sorted, this id references a valid database row, this enum value can actually only be a subset of the variants, etc. i agree with the “author” that rust is the best language for “correct” code that is also popular. but this isn’t how it is portrayed in the videos. and the part that is plain wrong is pretty simple: safe rust is not enough for very high performance code. and abstractions are not zero cost either - from a mental overhead and performance perspective. the simplest example of lacking performance is inlining: small functions (like getters & setters) do not get reliability inlined without the inline always attribute. if you call such a getter millions of times per second, it will show up in your profile. (it has happened to me on multiple occasions.) and again, yes rust seems like the language with the best out-of-the-box performance for average code (that is also a popular language). but that’s not what’s claimed in the videos. the videos make it look like the perfect language, which i understand to not be the opinion of the “author”, but i do wonder why they don’t actually say what they think about the language.
@NoBoilerplate2 жыл бұрын
There's a lot to unpack here, I think one of us is very confused. Let me try to clear things up: - You absolutely can express domain specific constraints like you suggested, there are design-by-contract crates and invariant crates that make use of the powerful macro system. - Getters and Setters don't exist in the language, are you thinking of Java? - Rust's type system absolutely helps you write correct code, in fact, I did a whole video on this topic kzbin.info/www/bejne/f3KXomOir9KsnK8 @leddoo, what I am sure we can agree on is Rust itself isn't perfect. I never have claimed such. For me, what Rust has is the perfect combination of COMPRIMISES. Haskell is excellent, and I love it. But I can't get work writing it. Coq can prove my logic, but I then have to translate it into imperfect C. I live in the real world, and I have to get paid to write as perfect code as I possibly can. For that reason, I'm excited about Rust.
@leddoo2 жыл бұрын
@@NoBoilerplate - so you do know about Coq - great! now imagine those types in rust. equality and other predicate types. clearly, you could express many more invariants this way. in rust you can't really write: "this function takes two arguments, and one needs to be a multiple of the other." or even something as simple as "an integer that is a power of two" with compile time checking (and having 2 times that integer still be a power of two). rust has this type "NotNull", which is a non-zero pointer. with richer types, there would be absolutely no need for that to be a distinct type. - bro no, i'm not talking about java. if you want a struct field to be "public read, private write", you have to make it private and have a public fn with the same name. but the getters/setters were more of an example of "small function, where the call overhead (push/pop stack) is greater than the actual work performed", so you want the call to be inlined. and that isn't reliably done in rustc, unless you use #[inline(always)] - yes, rust's type system can help you. and it does so much more than any other practical language i know. and that is also why i'm somewhat excited about rust. but i have also used it for a while now and know its limits. and i can see what the next language inspired by rust can look like.
@leddoo2 жыл бұрын
@@NoBoilerplate some more practical things you can't do in rust are: - "safe" memory allocators. because they require "proof" that a specific allocation belongs to a specific allocator and hasn't been freed yet. - using string asset identifiers (eg in a game) and have a compile time check that all those strings actually refer to real assets. and ideally replace the strings by some numeric identifier. the closest thing would be to generate an enum using some external process. but that complicates your build.
@leddoo2 жыл бұрын
just had a look at the `contracts` crate. very cool indeed! adding a bunch of runtime checks is very different though from compile time proofs and compiler checked "logical reasoning".
@NoBoilerplate2 жыл бұрын
@@leddoo You sound like you know what you're talking about! Thank you for this explanation. I believe much of what you want in Rust can be achieved today with the macro system, albeit not wholly at compile time (I can't find a good example, but something like crates.io/crates/contracts) The bottom line is that where Rust isn't perfect, you can write new language features using the macro system, so I don't look forward to the next language!
@lorenzodrea46402 жыл бұрын
meanwhile the c++ chad compiler giving you more info that you need and without helping you in the slightest
@NoBoilerplate2 жыл бұрын
Heh exactly.
@tannamnguyen44232 жыл бұрын
Your voice is so beautiful, hope you can share more stories
@NoBoilerplate2 жыл бұрын
Thank you so much, I Practice a lot! I've been producing a scifi podcast since 2020, I'd love to know what you think kzbin.info/www/bejne/pmTFdXhvoNitg8U
@reandov2 жыл бұрын
Your videos are amazing! Keep it up with them, please! I'm beginner in Rust, making my firsts steps and everything is just amazing, mostly when you come from a unreliable programming language such as JavaScript.
@NoBoilerplate2 жыл бұрын
Fantastic! Keep going, it's not as simple as JS is it? But totally worth it! I used doc.rust-lang.org/stable/book/
@CristianGarcia2 жыл бұрын
Haven't seen the video but just wanted to say that *sometimes* the compiler makes you feel like a 5yo trying to build Starship. Anyway, love language, will check out the video soon!
@NoBoilerplate2 жыл бұрын
Would love to know your thoughts
@commandlifeenespanol7628 Жыл бұрын
"A compiler that understands your program's memory exhaustively [also] understands your code exhaustively."
@NoBoilerplate Жыл бұрын
adding the 'also' changes the meaning, 'also' doesn't imply causation like the original sentence does, I think?
@VictorTaelin2 жыл бұрын
I've been programming for almost 20 years at this point, in small, big companies, for hobby projects, daily. I've used more than a dozen languages, including Haskell, for years. Haskell is definitely better theoretically. In practice, Rust is by far the best programming experience I've ever had.
@NoBoilerplate2 жыл бұрын
Really great to hear this from a pro, thank you Victor. I agree, I've been programming (primarily in Python) for 13 years, and I feel the same. If I could persuade the world to use Haskell, I would, I adore Haskell! But Rust feels like it snuck Haskell into the cool kids club in C's clothing!
@itellyouforfree72382 жыл бұрын
the one thing i miss from rust are higher ranked types. the one thing i miss most from haskell and rust is specialization (as in julia). i always feel i ought to prefer haskell above all others because it "feels right", but i'm too unproductive with it and cant control at all space/time execution performance. rust instead is just love at first sight
@NoBoilerplate2 жыл бұрын
@@itellyouforfree7238 Yeah, Rust doesn't have everything, but it's got so much right that I'm just delighted we have it, and it's so popular! What is Julia's specialization, I'm not familiar?
@itellyouforfree72382 жыл бұрын
@@NoBoilerplate i love rust too, it's my favorite at them moment, except when doing scientific computing, in which case i use julia. specialization is the possibility to have a generic `impl Trait for Type` and then a more specific `impl Trait for Type` for instance. this is not possible right now because one cant have overlapping implementations. this opens the door to all sorts of possibilities, the primary being optimizations. this is how julia deals with the multitude of mathematical objects you encounter in scientific computing. for instance, in a linear algebra library you may want to multiply matrices which are dense, sparse, triangular, symmetric, etc.. specialization allows to refine the generic algorithm to be better suited for the specific case
@NoBoilerplate2 жыл бұрын
@@itellyouforfree7238 ah right! Thank you for that info, it sounds like something that could be fixed in the future without breaking backwards compatibility. Fingers crossed!
@danielkodoh46792 жыл бұрын
Rust/typescript dev here. For the typescript example at 1:39 , there is a optional feature called noUnchekedArrayIndexing or something similar that prevents these kind of error from happening. It’s optional because the typescript community found it too verbose. But great video
@NoBoilerplate2 жыл бұрын
Oh many thanks! Not very experienced with TS, or Rust for that matter!
@lxdzii2 жыл бұрын
i am an undergrad student studying computer science, i have not reached this level of technical knowledge about languages, but your explanation of these high level concepts on programming languages made everything easy to understand! keep it up, also i haven't played much with rust, but what I'm getting from your enthusiasm for the language itself, is that its a really great language!!! i can't wait to play with it in the future ❤. you provide great video content too
@NoBoilerplate2 жыл бұрын
Thank you so much! Try starting here fasterthanli.me/articles/a-half-hour-to-learn-rust
@HelloThere-xs8ss2 жыл бұрын
Of course you're an undergrad in CS. Yes, it's very common now
@EnDungeoned2 жыл бұрын
Excellent! Keep them coming :) Your error is firmly bolted onto to a wall - which is bolted to the rest of the dungeon - which is probably bolted to a castle!
@ronensuperexplainer2 жыл бұрын
As an expert of modern C++ threading, I must admit that in Rust it's always easier to write superior multithreaded code.
@NoBoilerplate2 жыл бұрын
Super!
@Ariodan2 жыл бұрын
less than two minutes into the video and I hear a sneaky homestarrunner reference. excellent video!
@NoBoilerplate2 жыл бұрын
Everybody! Everybody!
@laundmo2 жыл бұрын
the rust compiler can also perform black magic. example: in the bevy game engine ECS you write systems by writing a function with queries as the argument types. you literally filter what you want to work on through just the type system. woaahhh. edit: to show, this is a bevy query for the player and moving the players position: fn move_player(mut query: Query){} this allows me to loop over all entities with a Player component and gives me a mutable reference to the transform component. its super neat.
@NoBoilerplate2 жыл бұрын
That's some clever macros working, I bet! Because Macros only run at compile time, they are SUPERCHARGED by having a rich type system. This is an advantage that Lisp macros never had. This is also how www.shuttle.rs works - it is able to examine your code and spins up infra based on what you are USING. Wild.
@terradoom85032 жыл бұрын
@@NoBoilerplate in this case actually, Bevy doesn't use macros (at least not in your code, anyway), just clever application of Rust's traits to do some type magic on normal functions. Also, I'd personally say Lisp macros are much more powerful, at least if you consider Common Lisp's reader macros, albeit at the expense of hygiene and ease of use.
@EmilySillyDev2 жыл бұрын
This video has actually convinced me to try rust. It looks really nice to work in!
@NoBoilerplate2 жыл бұрын
It really is! I learned from The Rust Book doc.rust-lang.org/stable/book/ and also Amos's blog: fasterthanli.me/articles/a-half-hour-to-learn-rust
@sobanya_2282 жыл бұрын
Kinda weird to chose that one error, that Rust also can't handle. And in rare situation, when the array is constant, Typescript also handles that (try 'as const')
@NoBoilerplate2 жыл бұрын
It's a bit of an odd choice, I suppose. I should have perhaps chosen a Vector for rust, as that's a runtime error. BUT my point that rust's errors are incredible would still stand!
@MrAbrazildo Жыл бұрын
2:37, I code that in C++, for runtime. It gives me the container name, its size and the index used, but don't give the command neither its line.
@andrewkovnat2 жыл бұрын
WOW. I have been very interested in Rust recently, and tried it out for myself. I got rather frustrated when I was slapping pointers indiscriminately on variables, and recieved errors... but I simply didn't know how SIMPLE the memory management was in Rust! It makes too much sense, treating variables like objects that can't have multiple abstract sources and writers! Thank you so much for this wonderful clarification! Rust's whole system is ripe for visual gags too, like a drawing featuring an apple being shared and eaten amongst friends.
@NoBoilerplate2 жыл бұрын
Keep trying friend! I had to power through the steep learning curve, but it's WORTH IT (As I hope my videos can show) Try fasterthanli.me/articles/a-half-hour-to-learn-rust
Thank you! I will! I've practiced my 'radio voice' for quite some time, do you know about my scifi podcast, Lost Terminal? I wrote the videos in Rust! kzbin.info/www/bejne/pmTFdXhvoNitg8U
@javidfarhan16752 жыл бұрын
When I first discovered iterators in rust, I spent all day using them wherever I could. Its really fun to chain iterators together to get things done. Then I found out about lifetimes.
@zyansheep2 жыл бұрын
rust really needs dependent types...
@NoBoilerplate2 жыл бұрын
Rust's macro system can build this! One of the things that makes me very optimistic about rust is that it has a macro system. This means that we don't need to wait for dependent types to be standardised in the standard library, anyone can add them using the macro system! I see people are experimenting crates.io/search?page=1&per_page=10&q=dependent%20types
@PatrickAlphaC2 жыл бұрын
I’m sold
@NoBoilerplate2 жыл бұрын
Dead easy to install with rustup.rs, I used the official book, which I recommend! doc.rust-lang.org/stable/book/
@WolfrostWasTaken2 жыл бұрын
Incredible video! Rust really seems like a language worth learning, and the community only seems to grow! I came in contact with Rust because I'm working on a Cosmos-based web3 project (smart contracts are all written in Rust), but now I kinda want to use it for my projects too! Do you think that Rust is mature enough to handle business complexity at scale while building a secure REST API?
@NoBoilerplate2 жыл бұрын
Absolutely my friend! Check out rocket.rs
@0ptikGhost2 жыл бұрын
Word of caution, a secure REST API has more to do with protocols than the language used to implement it. Rust is mature enough to build scalable software. How secure that software is depends on many factors beyond what Rust can help wih. There is a reasonably large class of bugs that Rust helps you avoid as long as you stay on the correct side of the safety hatch. But software implemented in Rust can still have software vulnerabilities. Due diligence and proper security design/development is still important.
@NoBoilerplate2 жыл бұрын
@@0ptikGhost Why did you say this? Your comment could apply to any language.
@john_paul_r2 жыл бұрын
@@NoBoilerplate I think you two are on the same page. My read of Edwin Castro's comment is that they're simply stating that you need to take the appropriate considerations for security in Rust, as with any language (i.e. Rust does not magically whisk away all of your security woes). I think they're just tempering expectations.
@NoBoilerplate2 жыл бұрын
@@john_paul_r Yes, that I agree with
@jmrumble2 жыл бұрын
Ahhhhh the voice of Lost Terminal! I love it!
@jmrumble2 жыл бұрын
It's dangerous to be alone. With Rust, you aren't. :)
@jmrumble2 жыл бұрын
... now I can listen to these (since discovering Lost Terminal) and imagine that friendly Seth is teaching me about friendly Rust :)
@NoBoilerplate2 жыл бұрын
That's so fun! XD
@benjinguyen99652 жыл бұрын
yes it does, but it also makes you question whether or not you were even good in the first place when you first start off. Took me a solid year of rust before I became comfortable working WITH the compiler rather than fighting it or blindly doing whatever to appease it. A year later, I am madly in love with it.
@NoBoilerplate2 жыл бұрын
Benji, we had the SAME experience with Rust! I HATED it to start with, I kept tripping up on little things like the two string types etc. I BEGGED my mentor to let me learn Go, but he kept giving me good advice, and explaining why Rust was going to be worth it in the end. And now look at us!
@brentsteyn66712 жыл бұрын
I don't think Rust is that hard anymore. It took me 1 month to understand all the basic and complicated stuff. This is not because I'm smart, there is know enough resources out there to make you competent in rust very fast.
@benjinguyen99652 жыл бұрын
@@brentsteyn6671 if you're able to understand lifetimes, how and when you can and cannot elide lifetimes, core Rust memory model concepts like why cell doesn't implement the sync trait, etc.. all within a month, I'd say you're a cut above the rest. Understanding the concepts for me at face value was one thing, but ingraining it into my intuition took time. Rust is a fundamentally different programming language, and it was difficult for me personally because I didn't have a C/C++ background, nor did I have experience with functional programming, all of which contain concepts that Rust adopted: Memory model aka atomics and ordering, monads, iterators, immutability by default, etc.. I come from Garbage collected language and only had experience with Go as it pertains to static types, so you can bet that picking up Rust took a lot of blood, sweat, and tears 😂
@0ptikGhost2 жыл бұрын
Rust, like Haskell, forces you to unlearn lots of bad programming habits. That is why it feels like you are fighting the compiler. You got away with bad programming techniques and Rust demands you abandon them or go into unsafe land. When you no longer fight the conpiler you have learned better techniques that you wish were better supported in other languages. And I do mean supported as most of Rust can be done in other languages, they just don't have support for these things out of the box and/or historical language defaults do not require enforcement.
@Nishandh_Mayiladan2 жыл бұрын
Thank-you for the comprehension !
@NoBoilerplate2 жыл бұрын
My pleasure! Rust was very hard for me to get into, the learning curve is TOUGH, so I started writing these inspirational videos for people to get excited about this incredible language :-)
@moiattube2 жыл бұрын
I admit, when programming in Rust I don't feel like a genius most of the time. Compiler messages are wonderful, true, and the lang itsef looks modern and enjoyable to code but… BUT I feel like a dumb when I'm not sure what's going on with my var when I pass it to that function or return it from my own function! Should I copy, own, ref, WHAT?! I've been programming with memory managed langs for 25+ years. With Rust, sometimes I doubt if I really know programming at all So no genius feeling here but a being a humble learner at best That said, this video is an excellent presentation of Rust Thanks
@NoBoilerplate2 жыл бұрын
I'm a learner too, for all my excitement about rust, I'm still progressing slowly! I can answer your question however: copy everything while you learn. Not the most efficient, but it will work.
@tsalVlog2 жыл бұрын
I've been using it for almost 2 years now, but YOUR explanation of the borrow system starting around 4:50 is the best I've found.
@NoBoilerplate2 жыл бұрын
That's impossible, I'm an idiot who doesn't know how to write Rust very well! But thank you!
@WilsontheWolf2 жыл бұрын
Honestly rust makes me feel like an idiot, due to the fact I have a hard time learning it
@NoBoilerplate2 жыл бұрын
It's so hard at the start isn't it! I started and stopped many times before I pushed through the initial phase! I promise it's worth it, friend. Re-watch my previous 'perfect' video on rust to get inspired! I found The Book to be a great way of learning doc.rust-lang.org/stable/book/
@Danielle_12342 жыл бұрын
"Everybody has a plan until they get punched in the mouth." --Mike Tyson Sparring with the compiler is a pain in the ass. There are so many concepts you have to learn to correctly code in Rust. It feels like you have to take multiple detours learning abstract concepts, but for each one you do learn the compiler becomes a friend. Don't fight with the compiler. Pause and instead of trying to solve your programming problem try to learn the programming concept deeply, then come back to your project.
@bozhidaratanasov7800 Жыл бұрын
Have watched the video before and I did agree. Right now, going deep into lifetimes and the different reference/pointer types, "Genius" is not exactly what I feel like.
@NoBoilerplate Жыл бұрын
You'll get there my friend, watch a few of my other videos to remind yourself of why you're powering through this difficult learning curve! :-)
@dudeguy79882 жыл бұрын
Rust makes me feel like a genius when I can actually understand what’s going on.
@NoBoilerplate2 жыл бұрын
same
@vikinggeorge7007 Жыл бұрын
2:30 - that's exactly because python doesn't compile. It's an interpreted language. Rust is a compiled language. C++ would catch this error here. But C++ has other problems with bounds checking (for loops, for example).
@feitingschatten12 жыл бұрын
C++ developers learned long ago (then forgot lately) that the "rules" Rust uses need to be adhered to. Who owns memory, when does it release... ensure you name things so "open" and "begin" have "close" and "end". I see your OOP handling safety in Rust and I'm like "Hey! That was in Windows Game Programming by Andre" books. I yell at people who blame C++ when it sounds like they just can't keep rules straight in their head. It's only a few rules, basic OOP, used to be taught in the 90's. Lately nobody learns good habits. It sounds like Rust forces this ownership concept that used to be developer decided. Sometimes a bit of freedom and rule-breaking is appropriate (for games, tricks you wouldn't do at an enterprise). For example, the bit-flipping that people used to compress things by storing values in unused sections of a pointer. Obscure, dangerous... but needed on 8-bit gaming.
@magnusanderson66812 жыл бұрын
Sure, but nowadays, we don't run software on 8-bit gaming machines and there's always `unsafe` if you really want it
@feitingschatten12 жыл бұрын
@@magnusanderson6681 It's not always unsafe if you have conventions in place to remember what you did, the same way a manual is safe to drive if you understand the clutch.
@magnusanderson66812 жыл бұрын
@@feitingschatten1 Yeah its obviously possible to write `unsafe` rust code that is actually still safe. But its possible 99% of the time to right safe rust code that accomplishes the same thing, so I don't understand why you would think that not needing to constantly keep that headache (especially on codebases that are larger than any single person can really understand) would be a bad thing. Again, if you really want to, you can just put `unsafe` around all your rust code. But why would you, when painless safety is one of the main features of rust?
@feitingschatten12 жыл бұрын
@@magnusanderson6681 I wasn't referring to rust. I was referring to the idea that you shouldn't stick to one tool just because something forced you. Tools are tools. They're not opinionated. You don't quit drawing just because the iPhone can detect a silhouette. You don't forget calculus basics because the calculator can do it. You wouldn't throw your bike away when you buy a car. Likewise you wouldn't remove your tools to accomplish tasks in a computer just because of someone's opinion, or even a hard-to-find bug. What's appropriate for the task is always what's appropriate as a neutral idea. Rust doesn't like me wielding the heap on my own, that's fine, it works the same as retainCount in practice. I can work with that. But I can also throw global things on the heap and later handle it if I wanted, in C++... and sometimes I may want to do that, for ease of reading or maybe to avoid writing architecture. Maybe it's only 1 hack and the engine is otherwise fine. Much like graphics context, which is basically the OpenGL Ram environment. In that case, unmanaged heap matches a mental model of the physical structure. If I wanted to write "proper" variables for the context antipattern then I'd funnel it through a bunch of things that are honestly unnecessary.
@NoBoilerplate2 жыл бұрын
You folks obviously know a lot more about this than me. I will say that it's my understanding that you CAN do whatever you like in Rust if you scope it inside an `unsafe` block. You can write Linux kernel modules in Rust (the only other language other than C to be blessed to do so) From that I imagine that many tricks to handle badly-behaving hardware are needed! Check out the Rustonomicon for this doc.rust-lang.org/nomicon/ And I will leave you with a counter to your first example, where you said as long as you know how to use the clutch, you can drive a manual car fine. The modern clutch is a very restricted, automated tool that strictly guides you into synchronizing correctly. Ask a trucker what they used to be like in the old days!
@topcivilian2 жыл бұрын
I am beginning my programming journey with Rust as my first language. After 'tutorial hell' and learning a bit of python, js, bash, etc. I discovered Rust and didn't turn back. Now I have a love/hate relationship with the compiler.
@NoBoilerplate2 жыл бұрын
Fantastic! Rust is a great tool to learn, but learning Javascript (and all it's problems!) would be a great second language too, just to be practical. My typical rust session would be: PAIN PAIN PAIN PAIN PA-Oh it's perfect and I'm done.
@topcivilian2 жыл бұрын
@@NoBoilerplate me: forget semi-colon compiler: "Your computer will now self-destruct in 5.. 4.. 3.. 2.. 1.." me: add semi-colon compiler: "Hello, world!"
@SaHaRaSquad2 жыл бұрын
Whenever I look at another language there's something disappointing about it in comparison. Usually compiler output & documentation, multithreading but also things like strings - Rust's handling of utf8 while still giving you access to every byte is great (I still wish there was a better way to get the char length though, this aspect is unnecessarily misleading).
@flyingsquirrel32712 жыл бұрын
The "char length" is almost never what you want. Either you want bytes if you care about the amount of data or you want graphemes if you care about the amount of letters/symbols. Counting code points (the "char" primitive in rust) doesn't make much sense for most applications. Also: the fact that you have to write .chars().count() is the opposite of misleading. It makes it very clear that there is no way to obtain the number of code points without iterating over the string. Hiding a costly operatiom behind a .len() function would be more misleading imho.
@NoBoilerplate2 жыл бұрын
This makes a whole lot of sense! Thank you!
@NoBoilerplate2 жыл бұрын
Yeah, I no longer get excited by new languages. I have started to wish people would write there new languages as rust macros! github.com/JunSuzukiJapan/macro-lisp
@SaHaRaSquad2 жыл бұрын
@@flyingsquirrel3271 Yes, len() is consistent with the rest of the API, but in pretty much all other languages I'm aware of which bundle length information with strings it doesn't mean the number of bytes. In Rust this is rooted in an implementation detail. "you want graphemes if you care about the amount of letters/symbols" Great that the stdlib only provides char counting and no information about graphemes, then. So much for not being misleading.
@tedelkington2808 Жыл бұрын
@noboilerplate hear hear on noting the fact that the machine doesn’t know what a type is and that it is just a logical construct for the humans. We should note this more often as a community
@NoBoilerplate Жыл бұрын
But just like how 'language', 'books', or the concept of 'love' don't exist in the physical word, these things are useful to us and should be cherished!
@gioac962 жыл бұрын
Ignore this comment, I’m just trying to show the algorithm that this channel is great by engaging with the content. Amazing video, keep it up!
@NoBoilerplate2 жыл бұрын
Ha! Thank you so much!
@aaronocelot Жыл бұрын
Great video: I sent it to some friends to propagandize them: one little note: *re this "cpu's don't know types, they only know ones and zeros" - mostly true, however see "stride size" on a typical DMA controllers. types are the bridge between ones-and-zeros and the real-world-modeling we superimpose upon them. it's the cookie-cutter shape of the data. We define struct types for the purpose of allocating discrete amounts and shapes of memory. It can also directly infer hardware execution paths, actual circuit switching: for example: If we look at an I2S stream going to an audio DAC, we can see the frame-clock toggling every two sample-boundaries (for a stereo audio track, multi-channel I2S being considered TDM already). The samples are real to the hardware, as are the frames.
@NoBoilerplate Жыл бұрын
Interesting! Thank you for the explanation :-)
@KillerMZE2 жыл бұрын
Rust seems awesome, great video that clearly shows the advantages. However, there's no way I'm going to convert millions of lines of C++ code in my ongoing projects
@NoBoilerplate2 жыл бұрын
Don't have to my friend. Rust was designed to work with c++ so you can just write one module at a time. Don't replace what's not broke! The FFI system is zero-cost.
@me6706311 ай бұрын
You had me hooked at the Strongbad reference at 1:30 :D
@voomastelka43462 жыл бұрын
You certainly have to be a genius to handle all the Rust's boilerplate for the data ownership. For instance, try your luck with cyclic references (e.g a tree where nodes have parent reference).
@NoBoilerplate2 жыл бұрын
My friend you're out of date! I believe you're talking about the challenge where A has a ref to B and B has a ref to A? How can the borrow checker clean that up? The simplest practical use of this pattern is a linked list, for which there is an implementation in the standard library doc.rust-lang.org/std/collections/struct.LinkedList.html How did they make this impossible structure? Using Rust's `unsafe` escape hatch: This is how you will find graph structures are built, the careful language and framework designers use this on tiny, heavily-audited, lines of the code to tell the compiler "I have checked this is valid behaviour, trust me". With rust, you can build safe interfaces on unsafe operations. In other languages, you must build entire unsafe PROGRAMS. If you ever have a data race, or memory overrun errors - you know EXACTLY where to look for these - inside the few lines of unsafe code. Have a look at doc.rust-lang.org/stable/book/ch19-01-unsafe-rust.html for more details
@johannes-vollmer2 жыл бұрын
With the ability to write macros in Rust, all boilerplate that could ever exist can be abstracted away
@voomastelka43462 жыл бұрын
@@NoBoilerplate I'm well aware that there are ways around that. I just want to point out, that Rust's *core safety feature* is too restrictive even for the fairly mundane data structures in its own standard library. If you look at the list of programming languages that don't have some sort of a built-in run-time automated memory management, then the only mainstream languages in it are C, C++ and Rust. The reason for this is very simple -- a garbage collector is a really useful thing to have and the only reason not to have one is when you can't have it for some technical reason (e.g. real time systems, tiny hardware etc). Otherwise it is always better to let the GC the memory management for you.
@NoBoilerplate2 жыл бұрын
@@voomastelka4346 The overwhelming majority of Rust code is safe code: In Rust, you can take the safety piecemeal. There are always areas where your code has to be unsafe, interacting with C code, or other native libraries, or even just interacting with The Real World! The genius of Rust is that you can build safe interfaces on unsafe code. You don't have to throw out the guarantees of Rust to do it. Example: If you want to interact with C code in Python, you write a C library with a Python interface. None of Python's guarentees (including the GC) apply to this C code you've had to write. In Rust, you write the smallest section of this using unsafe pointers you've TESTED REALLY REALLY WELL. And then build your safe Rust on top of it. I highly recommend checking out this doc.rust-lang.org/nomicon/meet-safe-and-unsafe.html
@Junior.Nascimento2 жыл бұрын
@@NoBoilerplate so, i cant make a safe linked list in rust? i will have to "assume" that my code works and its safe?
@saaddahmani18702 жыл бұрын
So amazing, for these reasons I love Rust.
@NoBoilerplate2 жыл бұрын
So good right?
@ShahJr2 жыл бұрын
I've always preached about languages like Rust and Elm that embrace type theory but since using Clojure recently I've also come to love it for it's no bs and data as code philosophy. The lack of a type system here is could even be called a feature in this case. While the stacktraces are no where near above mentioned languages, it doesn't seem to be a issue most of the times as shown by the community's response. What do you think of this stark contrast between these languages and why do you think the claims made in this video seldom impact Clojure development? How did the lisp family get away with ignoring the holy type system? Maybe you could even do a video if you are so fascinated by this as I am.
@batlin2 жыл бұрын
I'm fascinated by this topic too. I've enjoyed Haskell and Scala and a bit of Rust for a while, but I'm also swayed by Rich Hickey's assertions that problems of understanding the business domain, requirements etc are 10 or 100 times more time consuming than the errors a good type system helps you with.
@ShahJr2 жыл бұрын
@@batlin Exactly, hopefully we see more discussions and more importantly, research and studies such topics as the programming community evolves.
@NoBoilerplate2 жыл бұрын
Heh, if you have a glance at my upload history, you'll see that I actually used to love clojure, and did a video on it! I've also been a professional clojure dev for 2 years. Big fan. Rust has the best features of clojure and the best features of Haskell. From Clojure, it has the macro system, that treats data as code, and from haskell it has the powerful rich type system. All this in a package that has the C syntax that you seem to need for languages to be widely popular, and you've got something that isn't just technically good, but could actually become popular!
@Robert-ht5kd Жыл бұрын
1:26 Rightly so, no errors. Buyer of very expensive website shouldn't know that code was written by some teenager in India working for 5 bucks an hour.
@duftcola2 жыл бұрын
Bias....makes rust sound more than what actually it is
@NoBoilerplate2 жыл бұрын
I know I have the tone of a salesman, but that's because I genuinely think we have something very new and exciting here! I'm personally excited to learn rust because with what other language can I write code for a tiny microcontroller with no space for a GC, a lightning-fast backend that is only 1.1x as slow as C, and even targed the browser in webassembly! There's really something magic here. Have you seen my previous video "Rust: Your code can be perfect"?
@0.lennart2 жыл бұрын
This is the perfekt summary. Just so satisfying to write rust. You know when it runs, it works.
@NoBoilerplate2 жыл бұрын
Ah, I felt the same way about Haskell too! But Rust is something you can realistically get work in!
@cediwelli2 жыл бұрын
Everytime I watch a Video about Rust, I am more convinced that Rust is a cult.
@NoBoilerplate2 жыл бұрын
Why's that?
@cediwelli2 жыл бұрын
@@NoBoilerplate The way Rust-people talk about Rust and their subversive tone, trying to lure you into using the language. I get a similar feeling when watching C++ "Missionary" Videos but with Rust it feels more subconscious. I might give rust a try at some point in time but I feel tricked into a sect.
@NoBoilerplate2 жыл бұрын
@@cediwelli I understand that my videos are heavy on the sales pitch. I don't know how else to tell you that there's never been a language like Rust that is so popular that you might actually be able to use it professionally. I'm all-in, let's DO IT! A more down-to-earth person who loves rust is Amos over at fasterthanli.me/articles/a-half-hour-to-learn-rust
@cediwelli2 жыл бұрын
@@NoBoilerplate Thanks, I'll check out Amos. Your Videos aren't bad, they are quite informative. It's just the feel I get and you don't have to change your style, espeially if I am the only one who gets this feeling. You are pretty friendly and because of that I'll sub, maybe at some point I will get used to your style. Have a nice day.
@NoBoilerplate2 жыл бұрын
@@cediwelli Well thank you so much! I figure that we're all keen to learn, but youtube comments don't exactly foster a friendly atmosphere! Thank you for subscribing, I'll bear your comments in mind absolutely!
@AlexanderRau2 жыл бұрын
"Who is flying this thing?" 🤣 8:00
@NoBoilerplate2 жыл бұрын
I miss Firefly
@marusdod36852 жыл бұрын
yeah it's safe until you use unsafe everywhere because the compiler won't stop nagging you
@NoBoilerplate2 жыл бұрын
The unsafe block is explicitly not for turning off Rust's safety features. It's a little mis-named, honestly, and causes misunderstanding. Do watch my explanation here kzbin.info/www/bejne/hqawiYqZZd2lgZI
@marusdod36852 жыл бұрын
@@NoBoilerplate I know it's not, but you'll end up using it anyways
@NoBoilerplate2 жыл бұрын
@@marusdod3685 it doesn't turn them off. That's not how it works.
@FarazMazhar2 жыл бұрын
I am a fairly experienced Python main Data Engineer. I got Rust videos suggested out of the blue. After watching a few videos, you know what, I am gonna give it a go.
@NoBoilerplate2 жыл бұрын
That's my background too friend! You're going to have a great time doc.rust-lang.org/stable/book/
@FarazMazhar2 жыл бұрын
@@NoBoilerplate Thanks for making these videos. I started a few days ago. :)
@NoBoilerplate2 жыл бұрын
@@FarazMazhar Fantastic! Do watch all my videos, there's so much GOOD stuff in Rust that lots of people don't talk about (macros are my fav)
@atlantic_love2 жыл бұрын
Why would RUST make anyone feel like a genius? It doesn't do anything that C++ can't, and RUST's syntax is butt ugly.
@NoBoilerplate2 жыл бұрын
I know what you mean, Rust's got a lot of line noise doesn't it? I found that very tough to get past when I first started learning. It took me a while to realise that I was GETTING something from my investment in it: The compiler knows far more about your code than it could ever do without all the rich annotations. Regarding your second point, I'm afraid I can disprove that very easily: - C++ was rejected by the linux team as unsuitable for writing kernel modules with. Rust is about to be ratified, the only other language apart from C in their history. - Web programming in Rust is an absolute treat (backend with rocket.rs or webassembly frontend with yew.rs), you'll find few people wanting to code their apps in C++. - Rust solves safe memory management with the borrow checker. Once your C++ program becomes non-trivial, it appears to be impossible to avoid memory nightmares, which manifest as security holes so terrible that we give them names: Slammer worm, WannaCry, Trident exploit, HeartBleed, Stagefrieght, Ghost. The list goes on. Higher-level languages get memory safety by cheating with a Garbage Collector, but Rust keeps down at C's low-level by using perfect static analysis. It's really something! What sort of programming do you do, I presume you're a C++ coder? I'm learning so much about C accidentally while learning Rust, it's been really fun!
@atlantic_love2 жыл бұрын
@@NoBoilerplate Not by profession, I'm going through Stroustrup's newer C++ book, and I do know a fair bit of Python and JavaScript.
@NoBoilerplate2 жыл бұрын
@@atlantic_love oh snap! I'm a mostly python Web developer! Rust's benefits really rack up againt python: 80x faster, yet still being as high level as python. I find myself less satisfied with python these days, especially with indentation as blocks. Basically, as soon as I started doing a lot of yaml, I realised that braces are actually quite useful! XD
@rolandinnamorato19532 жыл бұрын
Great presentation, great pace, great voice
@NoBoilerplate2 жыл бұрын
Thank you! Do check out my other 3 rust videos and let me know what you think!
@Diamonddrake2 жыл бұрын
Have to disagree that “no errors” is inherently bad in the context you expressed. JavaScript not throwing an out of bounds error is just as much a feature as is anything else, using that one can shorten your code dramatically. It returns a falsey value which is very useful. It’s only an “error” to you because you decided it should be because it is in the languages you like. The idea that if it compiles it will probably work is a nice feature, but exchanging understanding for fighting your way to a compilation and assuming that means it’s right in this developers opinion is a trade-off not an objective improvement.
@NoBoilerplate2 жыл бұрын
I don't think this is a Good Part of javascript that you're defending. This pattern of returning some agreed-upon default instead of the type we expect (be it undefined, false, null, or -1) is something we're moving past as an industry. Typescript fixes this oversight, and forces you to deal with array[n] retuning an Option type, one that you must carefully interrogate for undefined before accessing. Even modern javascript has the `?` operator, which allows safe querying of deeply-nested objects, short circuiting on the first undefined. It seems even the language designers are improving the safety of this inherently bad pattern.
@Diamonddrake2 жыл бұрын
@@NoBoilerplate I disagree, that shortcut operator only works because of that so called “bad pattern” and undefined IS the agreed upon None value you seem to desire. Undefined Is a runtime type and you can check it while your code is executing not just at compile time. CPUs don’t know about types, but objects do have types that running code not just compilers are aware of. It’s data stored into structures. You can check if a value is undefined using typeof, but If you’re going to check if an index is outside of bounds and then return None. That’s exactly what JavaScript does by default. Index out of bounds and you get undefined. A real type that can be checked for both literally and loosely. Yes you can have more confidence in your code if you satisfy the type checker, but often you’ll jump through hoops to make it happy when you didn’t need to. You will also get over confidence in your tools and start to dumb your way to compilation instead of really thinking through a solution.
@MsKepher2 жыл бұрын
Great video. Errata: slide 21 "IS EQUIVALENT TO"
@NoBoilerplate2 жыл бұрын
thanks!
@OrbitalCookie2 жыл бұрын
I was evangelizing Rust to everyone, but they were all running away from me. It's hard being a genius.
@NoBoilerplate2 жыл бұрын
If you've not heard of The Blub Paradox, your eyes will be opened to why it's so difficult to persuade people of high-level languages features www.paulgraham.com/avg.html
@davidwayne99822 жыл бұрын
YES- I'm EAGERLY awaiting System 76 FINISHED POP OS totally written in RUST... soon as it comes out-- I'm getting it.
@NoBoilerplate2 жыл бұрын
Very exciting project!
@rifaldhiaw2 жыл бұрын
Great works! Keep it coming please.. Please do more rust video, love to watch how you explain a thing. Also thanks for making the font bigger in this video, since I usually watch from my phone as well.
@NoBoilerplate2 жыл бұрын
Phew! Yeah, the font thing was such a mistake on the previous video!
@fifty67372 жыл бұрын
rust is the perfect choice of something i want to learn next