Rust makes you feel like a GENIUS

Поділитися
Вставка
  • Опубліковано 14 тра 2024
  • A 10-minute lightning talk explaining why I think Rust is the most loved language.
    Start your Rust journey here: doc.rust-lang.org/stable/book/
    If you would like to support what I do, I have set up a patreon here: / noboilerplate Thank you!
    Transcripts for all videos here: github.com/0atman/noboilerpla...
    CREDITS & PROMO
    My name is Tris Oaten and I produce fast, technical videos.
    Follow me here / noboilerplate
    If you like sci-fi, I also produce a hopepunk podcast narrated by a little satellite, videos written in Rust! www.lostterminal.com/
    If urban fantasy is more your thing, I also produce a podcast of modern folktales www.modemprometheus.com

КОМЕНТАРІ • 1,4 тис.

  • @NoBoilerplate
    @NoBoilerplate  Рік тому +83

    ERRATA
    - Example at 6:26 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"

    • @NoC4k3
      @NoC4k3 Рік тому +6

      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)

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@NoC4k3 Thank you!

    • @henkoglobin
      @henkoglobin Рік тому +1

      @@NoBoilerplate At 7:09, the error says the value `vec` was moved, when the variable is actually called `users` in the code.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +3

      @@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!

    • @henkoglobin
      @henkoglobin Рік тому +2

      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!

  • @theRealPermagreen
    @theRealPermagreen 2 роки тому +1669

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +231

      I can't tell if you're complementing Rust or hate puzzle games!

    • @rallokkcaz
      @rallokkcaz Рік тому +70

      @@NoBoilerplate I think it's both but goddamn does it work!

    • @astral6749
      @astral6749 Рік тому +16

      Remember not to include unintuitive behaviors.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +82

      @@rallokkcaz No puzzle game ever let me write Linux kernel modules, so there has to be more to it than that XD

    • @theRealPermagreen
      @theRealPermagreen Рік тому +43

      @@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

  • @Yogii0000
    @Yogii0000 Рік тому +1715

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +339

      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

    • @harshmudhar96
      @harshmudhar96 Рік тому +213

      Also.. It's totally a fair comparison on static analysis when one of the languages is javascript, lol.

    • @mr.mirror1213
      @mr.mirror1213 Рік тому +16

      @@harshmudhar96 💀💀💀

    • @franciscomacedo5984
      @franciscomacedo5984 Рік тому +189

      Ah evangelism indeed, the fantastic world of Software as a Religion (SaaR)

    • @harshmudhar96
      @harshmudhar96 Рік тому +1

      @@PefectPiePlace2 ok ayaka.

  • @scheimong
    @scheimong Рік тому +172

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +10

      Isn't it joyful!

    • @brunocabral88
      @brunocabral88 Рік тому +14

      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..

    • @1SquidBoy
      @1SquidBoy Рік тому

      @FichDich InDemArsch you can do better than that

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +6

      @@1SquidBoy I blocked him, sorry for the trouble

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +26

      @@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!

  • @adileturaimov5952
    @adileturaimov5952 Рік тому +298

    You're like Bob Ross of programming: "Just look at this little happy error" 😂

  • @Hwyadylaw
    @Hwyadylaw Рік тому +34

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      All this, and it's popular, too! What a gift!

    • @raffimolero64
      @raffimolero64 Рік тому +4

      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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      @@raffimolero64 🦀

  • @BlunderMunchkin
    @BlunderMunchkin Рік тому +51

    I guarantee that I will still sometimes feel like an idiot regardless of what language I'm programming in.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +12

      Respect. Nothing wrong with being humble

    • @mostefajakboub2847
      @mostefajakboub2847 5 місяців тому +1

      your comment match perfectly with your profile picture

  • @thearyanahmed
    @thearyanahmed 2 роки тому +472

    Never thought I would watch rust video as bedtime story 😂
    Nice voice and storytelling sir!
    Btw, rust compiler sometimes seems like a mini AI.

    • @runtimejpp
      @runtimejpp 2 роки тому +2

      best idea thanks

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +34

      If you want me to ACTUALLY tell you a bedtime story, I produce a Hopepunk podcast called Lost Terminal narrated by a mini AI! ua-cam.com/video/p3bDE9kszMc/v-deo.html

    • @hezuikn
      @hezuikn Рік тому +4

      @@NoBoilerplate i cant wait for season 2!!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +5

      @@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 ua-cam.com/video/xBOTvsnP9Ug/v-deo.html

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@runtimejpp Start here ua-cam.com/video/p3bDE9kszMc/v-deo.html

  • @severinweigold9125
    @severinweigold9125 2 роки тому +110

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +42

      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!

    • @boiimcfacto2364
      @boiimcfacto2364 Рік тому +14

      @@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!

    • @jens6398
      @jens6398 Рік тому +12

      "A language that stops you making mistakes" - Followed by a subtle mistake... Not exactly advertising Rust here.

    • @remrevo3944
      @remrevo3944 Рік тому +16

      @@jens6398 Well, it would not compile, that's dramatically different then when it failed at runtime.

    • @mattshnoop
      @mattshnoop Рік тому +18

      @@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

  • @ItzKernel
    @ItzKernel 2 роки тому +409

    and this is why you can easily get addicted to programming in rust

    • @NoBoilerplate
      @NoBoilerplate  2 роки тому +37

      That's it! Very satisfying 😁

    • @PCB389
      @PCB389 2 роки тому +14

      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

    • @nexus4dev
      @nexus4dev Рік тому

      :/ Rust eventually will Die one day and no one will use it, but we have A LONG time before it will happen!

    • @ItzKernel
      @ItzKernel Рік тому +2

      well, everything will die eventually

    • @PCB389
      @PCB389 Рік тому +7

      Is better to rust out than wear out.
      -Some old guy

  • @microcolonel
    @microcolonel Рік тому +5

    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.

  • @RyanRussonDev
    @RyanRussonDev Рік тому +67

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +60

      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
      @shlokbhakta2893 6 місяців тому +2

      @@NoBoilerplateO.o

  • @darkchoclate
    @darkchoclate Рік тому +52

    Python - "list index out of range"
    He - "Python would not tell me what's wrong here"
    Python - "Am i a joke to you?"

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +9

      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

    • @darkchoclate
      @darkchoclate Рік тому +16

      @@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..."

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +6

      @@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

    • @TristramOaten
      @TristramOaten Рік тому

      @SomeName SomeOtherName OH GODS I'M GETTING PTSD

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +6

      @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.

  • @Hobbitstomper
    @Hobbitstomper 2 роки тому +19

    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.

    • @meamzcs
      @meamzcs Рік тому +2

      Since you can call into C code almost without losing any performance, a lot of bindings to C libraries exist.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +5

      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.

  • @rifaldhiaw
    @rifaldhiaw Рік тому

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Phew! Yeah, the font thing was such a mistake on the previous video!

  • @friendlybear5924
    @friendlybear5924 Рік тому +1

    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!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      You're too kind! Check out fasterthanli.me for really great in-depth rust tutorials from someone who actually knows rust XD

  • @Haiderali-qd1jy
    @Haiderali-qd1jy 2 роки тому +20

    Last week I subscribed, happy to see another rust video. Liked it

  • @n0xter95
    @n0xter95 Рік тому +8

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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)

    • @n0xter95
      @n0xter95 Рік тому +3

      @@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!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +3

      @@n0xter95 You're too kind! My next video will be on the magic of macros and why you should want them

    • @clonkex
      @clonkex Рік тому +3

      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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      @@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 !

  • @kevingonzalez2120
    @kevingonzalez2120 2 роки тому

    clear explanations, soothing voice. PLEASE, keep creating stuff!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      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! ua-cam.com/video/p3bDE9kszMc/v-deo.html

  • @abhishek.rathore
    @abhishek.rathore Рік тому +2

    Great video dude. Been learning Rust and I have been loving it since. Its awesome. Just like your content. Keep it up.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      Thank you so much, I really appreciate your words!

  • @OwO-.
    @OwO-. 2 роки тому +46

    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!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +7

      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

    • @leo848
      @leo848 Рік тому +1

      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.

  • @dorjegilfillan
    @dorjegilfillan Рік тому +7

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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!

  • @the_real_briel
    @the_real_briel Рік тому +1

    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!

  • @droox6372
    @droox6372 2 роки тому

    thats an excellent format of videos, totally like it👍
    and specially thanks about rust.
    i am new to this language and such videos gives me a clearer picture of how the rust works

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Welcome! The Rust book is how I started out, give it a try! doc.rust-lang.org/stable/book/

  • @themichaelw
    @themichaelw Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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)

  • @jacksonarnold27
    @jacksonarnold27 Рік тому +6

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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!

  • @pilotashish
    @pilotashish Рік тому +1

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Thank you! All of my videos will be like this! (Did you see my previous rust video?)

    • @pilotashish
      @pilotashish Рік тому +1

      @@NoBoilerplate yes really like your style. Subscribed

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@pilotashish I'm writing the next one now!

  • @tsalVlog
    @tsalVlog Рік тому +2

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      That's impossible, I'm an idiot who doesn't know how to write Rust very well! But thank you!

  • @stef4oben88
    @stef4oben88 Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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

  • @porky1118
    @porky1118 Рік тому +15

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +4

      Right! That's a great way of looking at it

  • @EnDungeoned
    @EnDungeoned 2 роки тому +1

    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!

  • @alejandrocelery3091
    @alejandrocelery3091 Місяць тому

    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!

  • @lxdzii
    @lxdzii Рік тому +7

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      Thank you so much! Try starting here fasterthanli.me/articles/a-half-hour-to-learn-rust

    • @HelloThere-xs8ss
      @HelloThere-xs8ss Рік тому

      Of course you're an undergrad in CS. Yes, it's very common now

  • @nderimtopalli3027
    @nderimtopalli3027 Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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/

    • @spicynoodle7419
      @spicynoodle7419 Рік тому

      Debugging JS (especially React) is terrible

  • @masterpommel7527
    @masterpommel7527 Рік тому

    Thank you! This video was phenomenal like the last one. I am learning so much!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Thank you so much! My code's not perfect, but I highly recommend Amos's blog for learning more! fasterthanli.me/articles/a-half-hour-to-learn-rust

    • @masterpommel7527
      @masterpommel7527 Рік тому

      @@NoBoilerplate Well, your code could be perfect ;)

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@masterpommel7527 It could be IF I COMPILED ALL MY CODE EXAMPLES (woops!)

  • @himboslice_
    @himboslice_ Рік тому +1

    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 :)

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      I can't believe it either, people love rust!

  • @NiDeCo
    @NiDeCo Рік тому +50

    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. 👍

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +31

      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)

    • @godofbiscuitssf
      @godofbiscuitssf Рік тому +2

      "the" smart way.

    • @NiDeCo
      @NiDeCo Рік тому +5

      @@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 ♥

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +7

      @@godofbiscuitssf Rich type system + functional programming is the right way. It's even snuck into javascript through React!

    • @godofbiscuitssf
      @godofbiscuitssf Рік тому +3

      @@NoBoilerplate Not for everyone, and certainly not for every context of programming.

  • @Tanimodoli
    @Tanimodoli Рік тому +4

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      Quite right, my example was not apples to apples. I should have illustrated rust's good errors with a better one, apologies!

  • @EmilySillyDev
    @EmilySillyDev Рік тому +2

    This video has actually convinced me to try rust. It looks really nice to work in!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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

  • @reandov
    @reandov Рік тому +2

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Fantastic! Keep going, it's not as simple as JS is it? But totally worth it! I used doc.rust-lang.org/stable/book/

  • @udianilbey
    @udianilbey Рік тому +6

    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".

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +4

      Thank you! The first idea is very important. You can make memory easy, but then you lose out on the power!

  • @elliott614
    @elliott614 Рік тому +3

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      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!

  • @martinslns
    @martinslns Рік тому +2

    still havent written any line of Rust and I'm already loving the "ownership" concept

  • @andydataguy
    @andydataguy 2 роки тому

    Your videos are great. Hope to see more rust content!

  • @eboatwright_
    @eboatwright_ Рік тому +4

    "You have to sit there and think about what caused your error. Because JavaScript is _certainly_ not going to tell you"
    SO TRUE!

  • @laundmo
    @laundmo 2 роки тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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.

    • @terradoom8503
      @terradoom8503 Рік тому

      @@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.

  • @0.lennart
    @0.lennart 2 роки тому

    This is the perfekt summary. Just so satisfying to write rust. You know when it runs, it works.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      Ah, I felt the same way about Haskell too! But Rust is something you can realistically get work in!

  • @F.a797
    @F.a797 2 роки тому

    Great quality video once again. Love it!

  • @WolfrostWasTaken
    @WolfrostWasTaken 2 роки тому +61

    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?

    • @NoBoilerplate
      @NoBoilerplate  2 роки тому +10

      Absolutely my friend! Check out rocket.rs

    • @0ptikGhost
      @0ptikGhost Рік тому +7

      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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@0ptikGhost Why did you say this? Your comment could apply to any language.

    • @john_paul_r
      @john_paul_r Рік тому +2

      ​@@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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@john_paul_r Yes, that I agree with

  • @corinnarust
    @corinnarust Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      You've captured my feelings too! This is why I started this video series!

  • @cerulity32k
    @cerulity32k 8 місяців тому +1

    Every variable has one thing, and every thing has one variable. Such a simple rule extends so far.

  • @bourehimyoussef111
    @bourehimyoussef111 Рік тому +2

    I never thought I would be on the verge of tears in front of a programming video.

    • @NoBoilerplate
      @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: ua-cam.com/video/p3bDE9kszMc/v-deo.html

  • @andrewkovnat
    @andrewkovnat Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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

  • @javidfarhan1675
    @javidfarhan1675 Рік тому +9

    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.

    • @zyansheep
      @zyansheep Рік тому +2

      rust really needs dependent types...

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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

  • @humayunmir5563
    @humayunmir5563 Рік тому +1

    great thanks for that! Very clear and articulate!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Thank you so much! I hope you like my other Rust videos, same style.

  • @zeenix147
    @zeenix147 Рік тому +1

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      Good point! I really need to consult with either a rust expert or the compiler for the next video!

  • @cocacodes
    @cocacodes Рік тому +19

    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?

    • @ericshimizukarbstein6885
      @ericshimizukarbstein6885 Рік тому +15

      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
      @cerulity32k 8 місяців тому

      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.

  • @VictorTaelin
    @VictorTaelin Рік тому +21

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +6

      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!

    • @itellyouforfree7238
      @itellyouforfree7238 Рік тому +1

      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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@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?

    • @itellyouforfree7238
      @itellyouforfree7238 Рік тому +2

      @@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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      @@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!

  • @saaddahmani1870
    @saaddahmani1870 Рік тому +1

    So amazing, for these reasons I love Rust.

  • @rolandinnamorato1953
    @rolandinnamorato1953 Рік тому +1

    Great presentation, great pace, great voice

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Thank you! Do check out my other 3 rust videos and let me know what you think!

  • @sobanya_228
    @sobanya_228 Рік тому +6

    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')

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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!

  • @ronensuperexplainer
    @ronensuperexplainer Рік тому +13

    As an expert of modern C++ threading, I must admit that in Rust it's always easier to write superior multithreaded code.

  • @Vagelis_Prokopiou
    @Vagelis_Prokopiou Рік тому

    Excellent info, excellent narration. Thanx!

  • @Nishandh_Mayiladan
    @Nishandh_Mayiladan Рік тому +1

    Thank-you for the comprehension !

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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 :-)

  • @tannamnguyen4423
    @tannamnguyen4423 Рік тому +3

    Your voice is so beautiful, hope you can share more stories

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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 ua-cam.com/video/p3bDE9kszMc/v-deo.html

  • @CristianGarcia
    @CristianGarcia Рік тому +4

    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!

  • @guilhermerodovalho9988
    @guilhermerodovalho9988 2 роки тому

    Great content bro, rust is really funny, and almost error prof.
    Looking forward for landing a job using rust

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      I wish you the best of luck! Microsoft are a big Rust employer, have a look at their job boards!

  • @ankk98
    @ankk98 Рік тому +2

    Impressed by the design of rust lang and the explanation of this guy.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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 :-)

  • @moiattube
    @moiattube Рік тому +10

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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.

  • @benjinguyen9965
    @benjinguyen9965 2 роки тому +5

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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!

    • @brentsteyn6671
      @brentsteyn6671 Рік тому +2

      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.

    • @benjinguyen9965
      @benjinguyen9965 Рік тому +3

      @@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 😂

    • @0ptikGhost
      @0ptikGhost Рік тому +1

      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.

  • @fortestingpurposesonly2697
    @fortestingpurposesonly2697 Рік тому

    enjoyed the video very much! Subscribed

  • @phillduffy
    @phillduffy 2 роки тому +2

    Such great quality videos, please keep them coming.

  • @WilsontheWolf
    @WilsontheWolf Рік тому +9

    Honestly rust makes me feel like an idiot, due to the fact I have a hard time learning it

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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_1234
      @Danielle_1234 Рік тому +1

      "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.

  • @SaHaRaSquad
    @SaHaRaSquad 2 роки тому +3

    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).

    • @flyingsquirrel3271
      @flyingsquirrel3271 2 роки тому +9

      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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      This makes a whole lot of sense! Thank you!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      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

    • @SaHaRaSquad
      @SaHaRaSquad Рік тому

      ​@@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.

  • @qgravy
    @qgravy 7 місяців тому +2

    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
      @NoBoilerplate  7 місяців тому

      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: ua-cam.com/video/oY0XwMOSzq4/v-deo.html

  • @me67063
    @me67063 4 місяці тому

    You had me hooked at the Strongbad reference at 1:30 :D

  • @gioac96
    @gioac96 2 роки тому +6

    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!

  • @feitingschatten1
    @feitingschatten1 Рік тому +6

    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.

    • @magnusanderson6681
      @magnusanderson6681 Рік тому +1

      Sure, but nowadays, we don't run software on 8-bit gaming machines and there's always `unsafe` if you really want it

    • @feitingschatten1
      @feitingschatten1 Рік тому +1

      @@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.

    • @magnusanderson6681
      @magnusanderson6681 Рік тому

      @@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?

    • @feitingschatten1
      @feitingschatten1 Рік тому +1

      @@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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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!

  • @emvdl
    @emvdl Рік тому +1

    Thank you, well done!

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Your too kind! have you tried Rust?

    • @emvdl
      @emvdl Рік тому +1

      @@NoBoilerplate Using it daily 😂

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      @@emvdl FANTASTIC! I can't say I'm not jealous :-)

  • @jmrumble
    @jmrumble Рік тому +1

    Ahhhhh the voice of Lost Terminal! I love it!

    • @jmrumble
      @jmrumble Рік тому +1

      It's dangerous to be alone. With Rust, you aren't. :)

    • @jmrumble
      @jmrumble Рік тому +1

      ... now I can listen to these (since discovering Lost Terminal) and imagine that friendly Seth is teaching me about friendly Rust :)

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      That's so fun! XD

  • @dudeguy7988
    @dudeguy7988 Рік тому +5

    Rust makes me feel like a genius when I can actually understand what’s going on.

  • @ShahJr
    @ShahJr Рік тому +5

    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.

    • @batlin
      @batlin Рік тому +1

      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.

    • @ShahJr
      @ShahJr Рік тому

      @@batlin Exactly, hopefully we see more discussions and more importantly, research and studies such topics as the programming community evolves.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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!

  • @JACKHARRINGTON
    @JACKHARRINGTON Місяць тому

    I put an exception in a match arm and it felt awesome

  • @e101sg
    @e101sg Рік тому +1

    Excellent presentation !! Like and love Rust :)

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Thank you so much! I've made 3 more, would love to know what you think about them!

  • @leddoo
    @leddoo Рік тому +4

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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 ua-cam.com/video/IA4q0lzmyfM/v-deo.html
      @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.

    • @leddoo
      @leddoo Рік тому

      @@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.

    • @leddoo
      @leddoo Рік тому

      @@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.

    • @leddoo
      @leddoo Рік тому

      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".

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      ​@@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!

  • @voomastelka4346
    @voomastelka4346 Рік тому +4

    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).

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +5

      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

    • @johannes596
      @johannes596 Рік тому +2

      With the ability to write macros in Rust, all boilerplate that could ever exist can be abstracted away

    • @voomastelka4346
      @voomastelka4346 Рік тому

      ​@@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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      ​@@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.Nascimento
      @Junior.Nascimento Рік тому

      @@NoBoilerplate so, i cant make a safe linked list in rust? i will have to "assume" that my code works and its safe?

  • @mahdirezazadeh5076
    @mahdirezazadeh5076 Рік тому

    Now the font size is great 🙂
    Thank you 😊

  • @Ariodan
    @Ariodan Рік тому +1

    less than two minutes into the video and I hear a sneaky homestarrunner reference. excellent video!

  • @KillerMZE
    @KillerMZE Рік тому +3

    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

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +2

      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.

  • @duftcola
    @duftcola 2 роки тому +3

    Bias....makes rust sound more than what actually it is

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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"?

  • @mrkyn
    @mrkyn 2 місяці тому

    What a beautiful video!

  • @tedelkington2808
    @tedelkington2808 9 місяців тому +1

    @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
      @NoBoilerplate  9 місяців тому

      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!

  • @cediwelli
    @cediwelli Рік тому +3

    Everytime I watch a Video about Rust, I am more convinced that Rust is a cult.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      Why's that?

    • @cediwelli
      @cediwelli Рік тому +1

      @@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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@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

    • @cediwelli
      @cediwelli Рік тому +1

      @@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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      @@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!

  • @Diamonddrake
    @Diamonddrake Рік тому +3

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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.

    • @Diamonddrake
      @Diamonddrake Рік тому +2

      @@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.

  • @user-cc8kb
    @user-cc8kb Рік тому +1

    You kinda sold me on it. I will learn some rust soon :) Thanks

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      Excellent! The official book is a great place to start, it's where I did doc.rust-lang.org/stable/book/
      Let me know if you need help!

  • @MrAbrazildo
    @MrAbrazildo Рік тому +1

    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.

  • @marusdod3685
    @marusdod3685 Рік тому +3

    yeah it's safe until you use unsafe everywhere because the compiler won't stop nagging you

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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 ua-cam.com/video/PuMXWc0xrK0/v-deo.html

    • @marusdod3685
      @marusdod3685 Рік тому +2

      @@NoBoilerplate I know it's not, but you'll end up using it anyways

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      @@marusdod3685 it doesn't turn them off. That's not how it works.

  • @OrbitalCookie
    @OrbitalCookie Рік тому +4

    I was evangelizing Rust to everyone, but they were all running away from me. It's hard being a genius.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      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

  • @Sandeepan
    @Sandeepan Рік тому +1

    3:47
    Love this

    • @NoBoilerplate
      @NoBoilerplate  Рік тому

      The errors or the Zelda reference? Either way, I'm delighted, thank you :-)

  • @topcivilian
    @topcivilian Рік тому +2

    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.

    • @NoBoilerplate
      @NoBoilerplate  Рік тому +1

      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.

    • @topcivilian
      @topcivilian Рік тому +1

      @@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!"