Rust Is Easy

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ธ.ค. 2022
  • Today I propose learning Rust in an unusual way: Let the compiler teach you.
    ❤️ If you would like to support what I do, I have set up a patreon here: / noboilerplate - Thank you!
    📄 All my videos are built in compile-checked markdown, transcript sourcecode available here github.com/0atman/noboilerplate this is also where you'll find links to everything mentioned.
    🖊️ Corrections are in the pinned ERRATA comment.
    🦀 Start your Rust journey here: doc.rust-lang.org/stable/book/
    🙏🏻 CREDITS & PROMO
    My name is Tris Oaten and I produce fast, technical videos.
    Follow me here / 0atman
    Website for the show: noboilerplate.org
    Come chat to me on my discord server: / discord
    If you like sci-fi, I also produce a hopepunk podcast narrated by a little AI, videos written in Rust! www.lostterminal.com
    If urban fantasy is more your thing, I also produce a podcast of wonderful modern folktales www.modemprometheus.com
    👏🏻 Special thanks to my patreon sponsors:
    - Affax
    - JC Andrever-Wright
    And to all my patrons!

ความคิดเห็น • 525

  • @NoBoilerplate
    @NoBoilerplate  ปีที่แล้ว +290

    ERRATA
    8:18 the windows installer is a console installer, not graphical, though you can double-click the installer. (or use winget install -e --id Rustlang.Rustup)

    • @scheimong
      @scheimong ปีที่แล้ว +17

      8:18 correction: the Windows installer is CLI, not graphical, although it can be launched with a simple double click.

    • @scheimong
      @scheimong ปีที่แล้ว +9

      Btw TH-cam offered to translate this comment into "ERRATUM all!()" which was funny

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +7

      @@scheimong oh that's fun, thank you I've never tried (I'd use WSL2 probably). Added!

    • @Michal_Peterka
      @Michal_Peterka ปีที่แล้ว +6

      Windows one line installer - if your windows already have winget tool or windows update containing it.
      winget install -e --id Rustlang.Rustup

    • @malbacato91
      @malbacato91 ปีที่แล้ว +1

      another correction: 6:57 - that is, not, what we did. similar, but not it.

  • @insideTheMirror_
    @insideTheMirror_ ปีที่แล้ว +373

    Find someone to love you as this guy loves Rust

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +64

      I mostly love not being paged by work at 4am :-)

    • @atharvnaik3282
      @atharvnaik3282 ปีที่แล้ว +2

      Nailed it

    • @user-rd9xk7ut7p
      @user-rd9xk7ut7p 3 หลายเดือนก่อน

      Impossible

    • @doods_0
      @doods_0 หลายเดือนก่อน

      Your mother?

  • @tylerbloom4830
    @tylerbloom4830 ปีที่แล้ว +532

    Addendum to "If the compiler is happy, I am happy": "If clippy is happy, I am very happy"

    • @tudbut
      @tudbut ปีที่แล้ว +3

      Yes!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +62

      Yes! I love running `bacon` (cargo install bacon) in clippy mode alongside my code. This is how I write this videos actually :-)

    • @jearlblah5169
      @jearlblah5169 ปีที่แล้ว

      @@NoBoilerplate bacon is sooooo cool!!!! you can even do bacon run or bacon test!!!

    • @dinofrog926
      @dinofrog926 ปีที่แล้ว +2

      @@NoBoilerplate what in gods name is 🥓

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +4

      @@dinofrog926 your life is about to level up! crates.io/crates/bacon
      I talk about bacon in my 'lightsaber' video, check it out!

  • @theroboman727
    @theroboman727 ปีที่แล้ว +543

    Two of my own notes that I think are important.
    1: Don't rely on the rust error messages that your IDE gives you.
    IDEs very often take some pieces of the error message but leave a bunch of details out.
    Whenever its not immediately obvious what an error is saying, go to the terminal and run `cargo check` or just `cargo c`, and you legit often get help messages as useful as the ones in this video.
    2: The compiler isn't always correct.
    The error messages can be extremely good, but the compiler does not know your intention.
    It can make a best guess, but its not always what you meant.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +145

      REALLY good advice here. I often run `bacon` (cargo install bacon) in a terminal alongside my IDE for this reason

    • @costelinha1867
      @costelinha1867 ปีที่แล้ว +71

      "The compliner doesn't know your intention"
      Yeah, fair enough, but honestly, even then I find these error messages pretty useful. Sure it might not be helpful ALL the time, but at least it's more helpful than the stuff I'd get from Python.

    • @DaveParr
      @DaveParr ปีที่แล้ว +38

      Interestingly new python errors (3.10 onwards I think) have started to look like rust. Multiline outputs with specifically pointy underlines it wants you to fix.

    • @avidrucker
      @avidrucker ปีที่แล้ว +7

      Bacon jokes aside, do you have a video on Rust bacon?

    • @dixaba
      @dixaba ปีที่แล้ว +12

      Most of the time (but not always for sure), rust-analyzer catches -stupid- obvious mistakes and suggests valid solutions for them. One of the best LSP servers I've ever used, across all languages.

  • @MilanRubiksCube97
    @MilanRubiksCube97 ปีที่แล้ว +80

    Never seen a compiler so happy while being abused in such terrible ways

  • @someghosts
    @someghosts ปีที่แล้ว +245

    I just want to build something one day that someone loves as much as this guy loves rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +58

      what I really love is *sleep*, and not to be paged at 4am ;-)

    • @agnishom
      @agnishom ปีที่แล้ว +6

      @@NoBoilerplate you have a pager?

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +6

      @@agnishom I *wish*. pagerduty.com calls my phone

  • @NStripleseven
    @NStripleseven หลายเดือนก่อน +3

    The transition from “your code doesn’t work, figure it out” to “your code doesn’t work, try this to fix it” is so extremely helpful that it halfway defines what makes Rust so great.

  • @AllemandInstable
    @AllemandInstable ปีที่แล้ว +39

    crazy how No Boilerplate's videos are the only ones making me more excited to code, even though I like coding already

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      It's RUST doing it to me! It makes me want to build stuff!

  • @jonyleo500
    @jonyleo500 ปีที่แล้ว +53

    As a python TA in college I feel that a good chunk of my job is reading error messages with students, that moment of realization is great. But this feels like a whole other level.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +9

      Yeah! Its important in python too, up to the limits of the language. Have you tried mypy?

    • @igorthelight
      @igorthelight ปีที่แล้ว +1

      Python is improving compile errors, inspired by Rust ;-)

    • @encapsulatio
      @encapsulatio ปีที่แล้ว +1

      Prologue lover?

  • @kochkochkoch
    @kochkochkoch ปีที่แล้ว +123

    As someone who started coding earlier this year and mostly worked with TypeScript, this honestly makes Rust sound a lot more interesting than I previously thought. JS frameworks have gotten me so used to useless error messages that having the compiler itself tell me what's actually wrong feels like a breath of fresh air.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +18

      Give it a go, try Rustlings!

    • @lucky-segfault4219
      @lucky-segfault4219 ปีที่แล้ว +13

      Rust is so good at turning runtime errors into compile time errors, I often won't run tests until I'm several hours into a project, and somehow it still works right first time (unless I forgot a todo!())

    • @kochkochkoch
      @kochkochkoch ปีที่แล้ว +1

      @@NoBoilerplate I got started with Rustlings yesterday and am continuing it this weekend. Honestly, I'm very impressed with it! Whenever I felt I didn't really know what to do, the hints were pretty helpful, as was the Rust book. I wish more languages had something similar to teach you their syntax and unique features, I love this hands-on approach.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      @@kochkochkoch I'm going through Rustlings with my team at work and I'm learning something every session too!

    • @kevinmcfarlane2752
      @kevinmcfarlane2752 ปีที่แล้ว +5

      If you’re in the client scripting space you might want to look at Elm, which has similar error messages. In fact I think Rust May have learnt this from Elm. Even if you can’t or have no intention of using Elm it’s worth looking at it once. We often learn from other tech even if we never actually use it directly.

  • @tudbut
    @tudbut ปีที่แล้ว +20

    i cannot believe it knows what other languages look like and can tell you how to translate.

  • @fabiolean
    @fabiolean ปีที่แล้ว +30

    I love this modern language design decision of having the language itself instruct the programmer. Elm does this spectacularly, and I'm excited to try it out in a lower-level language like Rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +3

      Great news! Though contrary to what most people will tell you, Rust isn't JUST a low-level language, it's also higher-level than Elm.
      Check out my video on this here th-cam.com/video/PuMXWc0xrK0/w-d-xo.html
      ALSO if you love elm, you might like Yew, which as the name suggests in inspired by Elm: yew.rs

  • @della.4593
    @della.4593 ปีที่แล้ว +51

    As someone who struggled with not just Rust but programming in general for a good while I find your videos second to none. I feel you don't just show how something is done, but also why you do it. Your videos helped me shake off bad habits, one of them being ignoring error messages. I must also say you just are a great lecturer, you can break down complex topics in super understandable language without compromising on info. Something I really admire.
    Great video as always. ❤

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +6

      Thank you so much for saying so Della, I really appreciate it! :-)

  • @b_dawg_17
    @b_dawg_17 ปีที่แล้ว +5

    This video reminds me of something my math teacher once told me: "my pen is smarter than I am". She meant that by writing down what I know about a problem, I give myself help by being able to see the problem one step further along. Helpful error messages are the unsung heroes of programming.

  • @sitton76
    @sitton76 ปีที่แล้ว +11

    I often describe the rust compiler as a helpful nanny, walking you through your mistakes and giving suggestions on how to correct them.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      Absolutely, in other of my videos I've described it as a driving instructor, helping you navigate the dangerous highway. Similar!

  • @Shnugs
    @Shnugs ปีที่แล้ว +15

    I've been doing Advent of Code using Rust because your series inspired me. I was kind of nervous picking up a systems language* because I made the mistake of trying to learn coding initially via C++. I've got a few years professional experience using JS, Python, and PHP now and have found learning Rust to be a delightful challenge.
    Keep up the excellent work!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Fantastic! Don't forget to .clone() if you get in a pickle, the performance hit will be *fine*.
      What did I say about it not being a systems language :-P Ok, I guess more accurately, is it's a universal language - systems AND high-level.
      Good going! come chat to me and the community on my discord server, there's an advent of code thread!

    • @dinofrog926
      @dinofrog926 ปีที่แล้ว

      are we the same person? I am also doing advent of code to learn rust because this guy’s series inspired me! I am currently on day 7 :)

    • @Shnugs
      @Shnugs ปีที่แล้ว

      @@dinofrog926 Bruh. Day 7 hit like a truck after 6.

    • @dinofrog926
      @dinofrog926 ปีที่แล้ว +1

      @@Shnugs haha yup! I started out researching how to do trees in rust. with ownership and no null pointers and everything it seemed difficult. then I gave up and continued reading the book instead :)

  • @TAINCER_
    @TAINCER_ ปีที่แล้ว +29

    Also very nice to use cargo clippy once in a while or use it in CI for bigger projects.
    It feels like a code review, only you don't need to wait for someone to actually do a code review :D Often with really nice code styling suggestions.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +4

      Yes! I love running `bacon` (cargo install bacon) in clippy mode alongside my code. This is how I write this videos actually :-)

  • @thatlittlefrog.
    @thatlittlefrog. 11 หลายเดือนก่อน +2

    I've been trying to learn rust on and off for a month now, your channel is really helpful, the videos are fast, straight to the point, and simply amazing.

    • @NoBoilerplate
      @NoBoilerplate  11 หลายเดือนก่อน

      Thank you! If you've not seen it, here's how I recommend you learn Rust th-cam.com/video/2hXNd6x9sZs/w-d-xo.html

  • @ElectronicaSovietica
    @ElectronicaSovietica 10 หลายเดือนก่อน

    This is a fantastic demonstration of the help you can get from the rust compiler. Also thanks so much for the link to rustlings - such a great way to learn: by debugging!

  • @cerulity32k
    @cerulity32k ปีที่แล้ว +7

    The errors you get from `cargo check` are better than the ones rust-analyzer gives you because the window that pops up when you hover over a red squiggly has less formatting than the console, which is a feat.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      Agreed, and `cargo clippy` even better!
      I run clippy in a separate window, even when I use my IDE, using crates.io/crates/bacon
      Check out my 'lighsaber' video for more info on my toolkit

  • @AzureFlash
    @AzureFlash ปีที่แล้ว +9

    "You need to add an ampersand here, dummy" - Rust compiler, millions of times a day across the world
    (I'm exaggerating for comedic effect, the Rust compiler is actually very nice about it)

  • @2raddude
    @2raddude ปีที่แล้ว +2

    Thanks again for another great video. I feel inspired to mess around in my IDE every time you publish. Having such powerful tools at my disposal really compels me to build something cool. Because Rust is so fast, I almost have the urge to build a program that crunches a ton of numbers on many different threads, just because I can :D

    • @2raddude
      @2raddude ปีที่แล้ว +3

      Sometimes having fantastic tools around can provide the inspiration for amazing projects. Woodworkers feel this sometimes, if you have a lathe sitting around in your shop maybe you'll get the idea to turn a gorgeous bowl or vase.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      RIGHT! This is how I feel about the Rayon library
      crates.io/crates/rayon
      you can make any iter a parellel iterator with par_iter() - WHICH I WANT TO DO NOW!

    • @2raddude
      @2raddude ปีที่แล้ว +1

      @@NoBoilerplate WHAT!?!? That might just be the coolest crate ever

  • @justriding119
    @justriding119 ปีที่แล้ว +4

    I am a javascript web developer (with some small knowledge of python and php). Just started learning rust and IT IS INCREDIBLE. A whole another world coming from javascript.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Isn't it lovely! I'm a python webdev and its like a new world!

  • @io_inc
    @io_inc ปีที่แล้ว +5

    Thanks to you and @Primeagen, i'm actually learning rust and hoping to port all my production applications to rust!!!
    Great Content!!!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      He's fantastic too, also check out Code To The Moon!

  • @alfaromeocharliehotelbravo928
    @alfaromeocharliehotelbravo928 ปีที่แล้ว +2

    Dude this was an exciting video! I can't wait to watch more like this. I'm currently at my 3rd day(77/94) on the Rustings exercises and It's damn good.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Nice! I love rustlings so much. Have you seen my whole Rust series? th-cam.com/video/Q3AhzHq8ogs/w-d-xo.html

    • @alfaromeocharliehotelbravo928
      @alfaromeocharliehotelbravo928 ปีที่แล้ว

      Yes, some of them. The more I learn about Rust, the more I like them 😃

  • @jumbledfox2098
    @jumbledfox2098 ปีที่แล้ว +4

    I'm 16, always been programming, from scratch to python to C++, but I've always felt that something was missing. You've shown me rust, and it not only feels like the missing piece has found, but a whole other darn contraption

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      If you are very lucky, you could use JUST RUST for your whole programming career - web, bare-metal chips, and everything in between. I'm hoping to only use Rust, now, for the rest of my career :-)

    • @jumbledfox2098
      @jumbledfox2098 ปีที่แล้ว +1

      @@NoBoilerplate Thanks for the reply! I hope to also only use Rust, it's really brilliant. Just wondering, I've been meaning to recreate this simple little scratch game as a rust web game for a little while now, do you have any pointers for me?

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      @@jumbledfox2098 Oh fun! Yes, though I've not done much game development, whenever I hear "game" and "Rust" in the same sentence, I also hear "Bevy".
      bevyengine.org/
      Come chat on my Discord (noboilerplate.org), there's loads of folks who could help you with it! Tag me and say hi 🙂

    • @jumbledfox2098
      @jumbledfox2098 ปีที่แล้ว +1

      @@NoBoilerplate Thank you!

    • @kaisershaik
      @kaisershaik ปีที่แล้ว +1

      ​@@jumbledfox2098did you just say… POINTERS?

  • @seraaron
    @seraaron ปีที่แล้ว +3

    As someone who's still learning programming, I'm happy to say that I haven't gotten into the habit of *only* reading the first line of an error code yet, though I do often duck it if I can't figure out what the rest means, so these error codes in rust seem like a godsend to me!

  • @ChannelSho
    @ChannelSho ปีที่แล้ว +2

    I remember doing the tutorials from the Rust book and got to the point where they deliberately made an error so the compiler would catch it and as soon as I saw what the compiler spit out I immediately went "okay, I'm sold"

  • @nightbane2889
    @nightbane2889 ปีที่แล้ว +1

    I only just bumped into this channel. I been itching a bit to try programming again...and not gonna lie, this is sounding VERY nice. Sure the complier isn't perfect as the comments pointed out...but the fact that the complier at least attemps to help you learn the language is something else

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Check out the rest of my Rust videos, I have them in a playlist, and then get cracking with The Book doc.rust-lang.org/stable/book/

  • @Hohmlec
    @Hohmlec ปีที่แล้ว +1

    I started learning Rust with lovely videos made by Tris. Thanks a lot

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      My pleasure, and thank you! Do join my Discord if you'd like help!

  • @philippecholet9484
    @philippecholet9484 ปีที่แล้ว +2

    I like your videos so much that I get out of my rss feed to like the video, every time, and read some nice comments.
    I did Advent of Code 2021 in two weeks last month (I'm might have too much free time though) and doing AoC 2022 🎄 in rust again, the compiler is my buddy.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Fantastic, and thank you very much!
      Have you tried bacon? (cargo install bacon) so good for running in a terminal while you code!

    • @philippecholet9484
      @philippecholet9484 ปีที่แล้ว +1

      @@NoBoilerplate Not yet, the error messages in my IDE (Sublime Text) when I save a file (with rust-analyzer I think, I don't remember how I installed it) are usually enough. But I'm gonna try it considering how much you like it.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@philippecholet9484 I don't think it has any complex dependencies, so you could test it out quite easily with a cargo install. I dive into my toolkit recs here th-cam.com/video/ifaLk5v3W90/w-d-xo.html

    • @philippecholet9484
      @philippecholet9484 ปีที่แล้ว +1

      @@NoBoilerplate I've seen all your videos (hopefully/sadly shorts enough) and this one **multiple** times.
      I tried bacon since my last comment: I like the "press one SINGLE key to change bacon job", I'll dive into its customization.

  • @olafbaeyens8955
    @olafbaeyens8955 ปีที่แล้ว +6

    Errors are also not always clear (for new people).
    I had a fight with "Futures" error and it turns out that the only thing you needed to do was to add ".await"
    The "borrowing" is also a big fight I once in a while have.
    In a lot of cases it is a trial and error until it compiles. Then you wonder what I did wrong and in the end Rust compiler is right all along.
    It is showing me potential errors I am not even aware of.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      There's work to be done, but its worth it!

  • @chrissaltmarsh6777
    @chrissaltmarsh6777 ปีที่แล้ว +5

    It is like C but without the danger - this is because modern machines can do all that cool analysis without your having to wait an hour for the compiler to strain through.
    I very much like it; gets me close to the metal where I am playing without the occasional frustration of working out why my foot is smashed up.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Yeah! I'm having so much FUN!

    • @chrissaltmarsh6777
      @chrissaltmarsh6777 ปีที่แล้ว +1

      @@NoBoilerplate I had a lot of fun back in the day hitting CAMAC interfaces to our particle detectors. But boy could you fall down the hole.
      Now I'm doing stuff on raspberry PI and I do not have to hobble around anymore. Rust is very clever.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@chrissaltmarsh6777 Cool! I'd love to do bare-metal on the pi

    • @chrissaltmarsh6777
      @chrissaltmarsh6777 ปีที่แล้ว +1

      @@NoBoilerplate You need to ask the compiler politely - 'I Really Really want to hit this address' And then you are cooking.
      Mind you, doing it with C was lots of fun as well. That frisson of fear.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@chrissaltmarsh6777 hehe I prefer less fear. I'd never have picked up a language with pointers if it weren't for Rust!

  • @felixfourcolor
    @felixfourcolor 3 หลายเดือนก่อน

    I love the idea of giving rust a completely different language and follow the compiler's error messages to transform it into valid rust. Can you make another video that expands on this idea, but with a less trivial codebase, like 100 lines?

  • @miguelguthridge
    @miguelguthridge ปีที่แล้ว +10

    I genuinely love Rust's helpful compiler messages, but sometimes its design is still far more difficult than other languages. For example, a few weeks back, I was trying to create a system where struct instances could register one of their FnMut methods with a plugin manager to use it as an event callback if certain criteria were met, but the lifetime requirements sadly got too out of hand for me to implement it in a reasonable amount of time. I'd really appreciate a video explaining how to tackle the more complex (usually lifetime-related) issues that the compiler can give, since although Rust makes the easier parts very easy, it can make complex systems much more challenging to write when you don't know how to tackle these sorts of issues.

    • @philippecholet9484
      @philippecholet9484 ปีที่แล้ว +3

      Yeah lifetimes are not easy. I'm still in the "is the compiler happy with this lifetime change? Or this one?" phase.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      clone everything my friend! Though you sound like you know how to do it.
      In your case, I'd re-consider your design, it sounds like you're working against the compiler - Rust has a way of doing things that is very strict, what we get is compile-time verification of our model, what we lose is the ability to write anything we want. I'm happy with this compromise!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      instead of using references, try .clone()ing everything while you're learning :-D

    • @miguelguthridge
      @miguelguthridge ปีที่แล้ว +1

      @@NoBoilerplate yeah I think the issue is that I need it to be stateful, so if I'm cloning everything I lose the shared state for all the callbacks associated with one struct

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@miguelguthridge You, my friend, do not need my help! Come ask in #programming on my discord server if you like, there's some geniuses over here!

  • @duckhuntergaming4713
    @duckhuntergaming4713 ปีที่แล้ว +1

    I've been working on designing a system's programming language for a couple of months now, and I have to say your videos made me heavily interested in Rust. Being a long time C programmer who has worked on kernel development, nothing has rocked my understanding of imperative languages and type systems as much as Rust has.
    The main areas we have identified in our PL design efforts are the type system (classes and oop stuff is a sub category), primitives for pre emptive/cooperative/distributed parallelism, structured programming primitives (loops, branching mostly), error handling, meta programming (generics, macros), syntax + semantics and most importantly increasing cohesion and decreasing inter component coupling.
    Rust addresses most of these problems so well that we're left wondering if there's still meaningful room for improvement. I would love to discuss these aspects of the language as well as generally, and I would love to know what you think are some shortcomings of Rust and other system's languages you may be familiar with.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      I'd love to chat about this too, join my discord (links in video description) and ping me in #programming - there's lots of smart folks who are interested in language design!
      Here's a tip to start off: Because Rust has a proper lisp-style macro system, you can write your language INSIDE rust, not just USING rust. That way you get all of the language features you love for free (including lsp ide support). Here's an example that might blow your mind:
      github.com/JunSuzukiJapan/macro-lisp

    • @KohuGaly
      @KohuGaly ปีที่แล้ว +2

      The one area where big improvements are due in Rust is the implementation of its type system. At the moment, it has some nasty limitations.
      Do you want to make a trait method const? or async? or use impl in return type? or make async closure? well, too bad, not supported yet.

  • @Thorhian
    @Thorhian ปีที่แล้ว +1

    Thanks for the awesome video! Also, is this a Norg slideshow lol?

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Obsidian.md slideshow! See the description for source repo

    • @Thorhian
      @Thorhian ปีที่แล้ว

      @@NoBoilerplate Obsidian sure does look nice. I don't think I really need it that badly, and no commercial use or FOSS version is kind of a turn away.

  • @olafbaeyens8955
    @olafbaeyens8955 ปีที่แล้ว +12

    One of the big resistance to Rust is the fact that Rust code can look very messy. Full of ".unwrap().unwrap().to_string()."
    For new developers that look at it, it is scary. And also gives the impression that it produces bloated code hard to maintain.
    It is hard to convince managers that you are not wasting time but also your fellow developer colleagues.
    However I did manage to create (currently sloppy code) that can execute 1000 parallel threads to test a web site.
    Not only did I do this in a faster development cycle than any C# program would, I suddenly have the freedom to go beyond any C# capable code. I develop faster because I trust the Rust compiler to catch any mistakes I make.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      The way I look at it, unwrap()s are for protyping code - take a look at my vide Rust On Rails for my recommendations here

  • @eboatwright_
    @eboatwright_ ปีที่แล้ว +2

    Cargo is _literally_ the best package manager I've ever used, and probably will ever use.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Let's not get religious - we'll continue making better languages forever! But Rust is the best for now :-)

    • @eboatwright_
      @eboatwright_ ปีที่แล้ว

      @@NoBoilerplate Definitely

    • @neoney
      @neoney ปีที่แล้ว +1

      rustc is the compiler :p

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@neoney fair, though I think it's reasonable to wrap up rustc, check, clippy etc into "cargo" 😂

  • @wackender9542
    @wackender9542 6 หลายเดือนก่อน +1

    Also just started learning rust, and I noticed the compiler almost immediately becaus of it's quality. But didn't know it was that good.

    • @NoBoilerplate
      @NoBoilerplate  6 หลายเดือนก่อน

      so lovely, isn't it!

  • @martinemanuel8239
    @martinemanuel8239 ปีที่แล้ว +1

    This channel gives me a feeling of love to a low level language like C when I started learning to program, I will go for rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Its really incredible isn't it!

  • @nikolausluhrs
    @nikolausluhrs ปีที่แล้ว +4

    I think this is going to be the video that finally gets me to learn rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Give it a go! Rustlings is such a great resource to teach through doing

  • @justcodingjumperbot_
    @justcodingjumperbot_ ปีที่แล้ว +3

    I am now fully tempted to learn Rust like how I learn other languages: Mess with the compiler.
    And yes, I'm tired with sub-millisecond Java code now.
    Maybe I'll just finish that feature I was working on and then migrate the whole UFB project to Rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      You'll have a terrific time. I know what you mean, compiler-driven development is fun, especially so in Rust.
      Here's my recommendation on how to dive in: th-cam.com/video/ifaLk5v3W90/w-d-xo.html

  • @funkemunky
    @funkemunky 11 หลายเดือนก่อน +1

    This definitely changed my view on Rust. It appears my main issues with it resulted from my under-utilization of the compiler output

    • @NoBoilerplate
      @NoBoilerplate  11 หลายเดือนก่อน

      My next video is how to speak rust compiler jargon. It's really beautiful in simple cases, but of course as you get more complex, the output gets denser. It all can be understood, though 🙂

  • @Felix-ve9hs
    @Felix-ve9hs ปีที่แล้ว +2

    I'm not a programmer, but IMHO this is what all compilers should do. Error messaged should have a meaning.
    Without that It's like a firewalls that logs "I guess someone is attacking your network" or or syslog telling you that "one of your programms stopped working".

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +2

      Wild that most languages dont, right? I think the langues with the best errors also have a lot of syntax - which makes sense, I think, as that gives more clues to the compiler

  • @Techieadi
    @Techieadi ปีที่แล้ว +3

    Once a legend said "read the error AGAIN!!"

  • @OzoneGrif
    @OzoneGrif ปีที่แล้ว +5

    I'm a Java dev and I want to learn Rust so badly; it seems like an amazing language.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +3

      That's great news! You'll have no problem learning it, it's very easy to learn. Many of Rust features are shared with Java (such as the Optional type), but Java, by it's complicated nature, can't implement them properly.
      Try : 1. The Rust Book. 2. Rustlings 3. everything on fasterthanli.me

    • @BurzowySzczurek
      @BurzowySzczurek ปีที่แล้ว

      My main language is java too, and I plan to learn rust too. I had started reading the rust book around a month ago. I finished the chapter 2. and started reading 3. But then I got busy and forgot about that. But now after two of your videos i'm lying in my bed at 23:48 (11:48 pm) and thinking about going back to learning rust tomorrow.
      Thanks for the hints.

  • @thomasfrans1185
    @thomasfrans1185 ปีที่แล้ว +2

    These videos are so good. They make Rust even better!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Other way around - rust is so good I am doing everything I can to make it more widely known

  • @gamechanger1222
    @gamechanger1222 ปีที่แล้ว +2

    I love the voice of this guy, now as go programmer i love rust too.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      You're too kind! I've perfected my voice on 11 seasons of my hopepunk/scifi podcast, Lost Terminal, what do you think of it? th-cam.com/video/p3bDE9kszMc/w-d-xo.html

  • @borat1
    @borat1 ปีที่แล้ว +1

    holy crap, you actually run LT? I've been binging it after I found it on another one of your vids. Great podcast!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Sure do! And Modem Prometheus, though I don't voice it, I'm producer. And a new podcast in pre-production coming in the new year... STAY TUNED!

  • @aryabp
    @aryabp ปีที่แล้ว +4

    you not come to RUST, RUST come to you

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Ah yes, rule # of our cargo cult XD

    • @cold_ultra
      @cold_ultra ปีที่แล้ว +1

      no one is safe from oxidation...

  • @ReedoTV
    @ReedoTV ปีที่แล้ว +6

    1 crucial piece of advice:
    If you end up using an Arc, delete everything and start again.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      heh, certainly in application code, you'll not have to do that

  • @FishyBearBeer
    @FishyBearBeer ปีที่แล้ว +15

    I feel like a child being walked through homework. It's that easy!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +3

      The compiler really holds your hand!

  • @thanatosor
    @thanatosor ปีที่แล้ว +1

    What a lovely compiler !
    99% reason behind my pick on Rust, beside borrow-checker, no GC, high perf and every other nice things.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      even macros! What a delightful language.

  • @stxnw
    @stxnw ปีที่แล้ว +1

    Yes, "cannot borrow `x` as mutable more than once at a time" is soooo helpful.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      That sounds pretty clear to me?

  • @TonyUnderscore
    @TonyUnderscore ปีที่แล้ว +2

    2:35: "It doesn't seem like we are writing a method" I'm assuming you meant to say "a *self* method", love your channel!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +5

      functions are not called methods in Rust, unlike in Ruby. I don't think I'm wrong?

    • @TonyUnderscore
      @TonyUnderscore ปีที่แล้ว +2

      ​@@NoBoilerplate Ah I see what you mean. Did not realize that they actually mean a different thing. So methods are those attached to structs while functions are not? In any case, you could probably make a clarification for those that are unaware.

    • @avidrucker
      @avidrucker ปีที่แล้ว +1

      My understanding is that methods bound to classes/objects, whereas functions are not. Similar to attributes/member data and variables.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@TonyUnderscore exactly, methods are functions attached to types doc.rust-lang.org/rust-by-example/fn/methods.html

    • @TonyUnderscore
      @TonyUnderscore ปีที่แล้ว +1

      I see, I never realized they actually mean different things because I heard them used interchangeably in some languages, good to know I guess.

  • @SimGunther
    @SimGunther ปีที่แล้ว +1

    Very much the same as a dojo instructor giving you instant feedback, but they're not a mind reader, so being clear about your intentions helps them give you better feedback.
    Too bad that it can't tell whether or not I "meant" for the program flow to go one way only for it to go a completely different direction as far as high level program design is concerned.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Agreed, though with sum types (ie, Rust's enums), you can express your intent much better than in languages that don't have sum types!

  • @nyxalexandra-io
    @nyxalexandra-io ปีที่แล้ว +1

    yayyyyy
    Also accurate to my experience with Rust

  • @ahuman32478
    @ahuman32478 10 หลายเดือนก่อน +2

    Started coding in Rust yesterday. I'm working on the PNGme practice project. The compiler doesn't make coding as easy as this video makes it seem. The compiler keeps on giving me weird errors about Boxes, Dyn, etc, and most of the time doesn't spoonfeed me the answers like I was expecting. Plus, I'm struggling with using iterators. Also, there's a lot of nuances to the language, like when to use into_iter or iter, when to use unwrap or expect or the ? operator.
    The only thing that keeps me going is knowing that this is way easier than C++, yet just as performant. I struggled with CMake, Dlls, etc. trying to import the SFML graphics library into a C++ project. Soon, I just decided to give up on it. With Rust, I know that Cargo has my back to make importing and using dependencies a breeze. Plus, I'll never get a SegFault. All I gotta do is keep on going, even when it feels like I'm wasting my time on this

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      Pause right now and complete Rustlings, then go back. My recs here: th-cam.com/video/2hXNd6x9sZs/w-d-xo.html

    • @ahuman32478
      @ahuman32478 10 หลายเดือนก่อน +1

      @@NoBoilerplate Hello, I am enjoying Rustlings. I got stuck on the Clippy exercises, but then found out that I just have to compile the exercises to get the Clippy feedback

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      @@ahuman32478 You've got it! run `rustlings watch` to get the nice feedback (bacon style), and don't forget to run `rustlings lsp` once to set up vscode's hints and such, with Rust Analyzer.

  • @Big-Chungus21
    @Big-Chungus21 10 หลายเดือนก่อน +1

    Definitely going to have to learn Rust at some point then. I like how useful the errors output by the interpreter in Python are for example, and this is even better. Errors in C++ from my experiences so far are… not very useful by themselves.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      You'll have a really great time, here's a little playlist to get up to speed quickly, though I have plenty of videos elsewhere! th-cam.com/video/oY0XwMOSzq4/w-d-xo.html

  • @RemizZ
    @RemizZ ปีที่แล้ว +3

    It's insane that even though you *just* told me to actually read the error, my immediate reaction to the first error dump was to not even read the first line properly. This will be a very hard habit to break...

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Whatever language we use, I bet this is a good habit to break!

  • @porky1118
    @porky1118 ปีที่แล้ว +1

    One of your best videos so far.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Thank you so much, I'm so pleased with it - I ditched the video I was going to produce this fortnight, and instead did this one - rewriting everything on Tuesday!!

  • @LukasMosser
    @LukasMosser ปีที่แล้ว +1

    Important to note that the help statements where only available after updating to rust 1.65

  • @navjotsingh2251
    @navjotsingh2251 ปีที่แล้ว +1

    Imagine if they incorporate an alternative to GitHub copilot to the rust compiler, so that the help will use the power of machine learning similar to copilot that recommend solutions as well based on code it has trained from. Would be interesting to see using that to help you develop using rust too.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      I see them as two distinct projects - the ML algorithm is probably right, but the compiler is DEFINITELY right!

    • @navjotsingh2251
      @navjotsingh2251 ปีที่แล้ว

      @@NoBoilerplate it was just a thought. Would be interesting to maybe get two recommendations, a compiler recommendation and maybe a machine learning recommendation (based on the best code solution it could find) to help you fix an error. Not sure how easy it is to add this directly to a compiler and make it run smoothly, but it was a little idea in my head 😅
      Maybe this could be researched to see it's practicality in the real world.

  • @nichtgestalt
    @nichtgestalt 3 หลายเดือนก่อน

    I know nothing about programing and I'm not sure if I have the talent for that but it is tempting to give it a shot.

  • @blueninja012
    @blueninja012 2 หลายเดือนก่อน

    this video made me realize that I have some weird deep-rooted fear of reading error messages

  • @JeffHanke
    @JeffHanke ปีที่แล้ว +1

    This is a great idea for a video!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Thank you! Funny story, I had written an entirely different video for today, but on Tuesday I had this brainwave and wrote this video instead! I'm delighted.

  • @qm3ster
    @qm3ster ปีที่แล้ว +2

    Would be good to see some clippy rubbed on this exact example, as part of the video, or a follow-up.
    By default, it got rid of the unnecessary `return`, but with #![warn(clippy::pedantic, clippy::nursery)], it also told us to accept &str instead.
    Seems like it hasn't yet been taught to see `format!("hello {name}")` as preferable here, though.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Very correct! I was ignoring a lot of clippy errors during my testing here, in order to get the most bare-bones rust experience, for newbies.
      I love clippy, and run it with those and many other options inside a `bacon` session, alongside my ide!

  • @nyuh
    @nyuh ปีที่แล้ว +1

    whoa i knew the compiler was advance but i didnt know it is THIS advance. maybe i need to try to start learning it again...

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      It's got SO much better since I started in 2020!

  • @bil4x467
    @bil4x467 ปีที่แล้ว +1

    This is so true! I noticed this coming from C languages to Rust.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Best errors in the business!

  • @gigacool30
    @gigacool30 ปีที่แล้ว +1

    Coming from C++, Rust compiler output is a miracle

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Hell, coming from python, js, ruby etc, it's still a miracle!

  • @ahuman32478
    @ahuman32478 10 หลายเดือนก่อน +1

    Hi. I've been watching your Rust videos for a while and I want to start programming in Rust now. I installed Rustup and am trying to configure my workspace right now. Rust is asking me to install MSVC build tools, but they're also offering me the option to skip ahead if I'd rather use the GNU ABI. Would you recommend using the MSVC toolchain or go the GNU pathway? I believe that software should be able to support all platforms, so I want to make sure my applications support Windows, Mac, AND Linux

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      Cross-compilation is trivial in Rust, so you can usually code on one platform, and make binaries for any other platform.
      I'm uncertain about developing on windows, however, I've heard that it's best to use WSL2, to give a much nicer experience.
      WSL is really great these days, and will side-step this, and many other issues you'll face learn.microsoft.com/en-us/windows/wsl/install

    • @ahuman32478
      @ahuman32478 10 หลายเดือนก่อน

      @@NoBoilerplate Tbh my computer is on the verge of running out of memory, less than 10 gigabytes left. Got no room for a Linux subsystem. But I will take your advice that cross-compilation is easy no matter the platform and use MSVC since it's the recommended toolchain for Windows. Thanks

  • @4sat564
    @4sat564 ปีที่แล้ว +2

    Best Rust preacher ever

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Welcome to the cargo cult! XD

  • @awwastor
    @awwastor ปีที่แล้ว +2

    The compiler being happy doesn’t mean there are no memory leaks. Box::leak is safe, although it makes it obvious that memory is being leaked. But, creating an Rc cycle will also leak memory and might well be accidental

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      True! A few people have reminded me of this. Would you say in general terms, you'd have to TRY HARD to leak memory in Rust?

    • @awwastor
      @awwastor ปีที่แล้ว

      @@NoBoilerplate Well it's easy if you want to leak it (which is good, it's sometimes useful). I think it really depends on the abstraction you use, if you use the Rc type to make graphs or other complex shared ownership data structures, especially intrusive ones, you may well encounter some leaks. If you don't then it is quite rare

    • @KohuGaly
      @KohuGaly ปีที่แล้ว +1

      @@NoBoilerplate I'd say in Rust, memory leaks are as unlikely to happen by accident as in most GC languages. You can do it on purpose with Box::leak. You can do it by accident with Rc-based graphs. But littering Rc liberally is already a red flag, tbh.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@KohuGaly Righto - makes sense! Yes, Rc is useful, but spooky - I think in normal use, we'd just use references and not have a problem!

  • @donparkison4617
    @donparkison4617 11 หลายเดือนก่อน +1

    Honestly, this is why I have always leaned towards C# and avoided Javascript. It might not have the best explanation of compile errors, but it beats the heck out of everything else I have used.
    Just started my Rust journey, and I am excited to code again.

    • @NoBoilerplate
      @NoBoilerplate  11 หลายเดือนก่อน

      You're in for an absolute TREAT Don, make sure you've watched at least this playlist, and my "how to learn rust" video th-cam.com/video/oY0XwMOSzq4/w-d-xo.html

  • @TheCollectiveHexagon
    @TheCollectiveHexagon 3 หลายเดือนก่อน

    8:10 ik the link is on screen but would be nice to have it on description/on the pinned comment so people can find it(if they got low vision/blindness/any other reason) too :)

  • @warisulimam3440
    @warisulimam3440 7 หลายเดือนก่อน +1

    This video was convincing enough to get me to start learning Rust immediately.

    • @NoBoilerplate
      @NoBoilerplate  7 หลายเดือนก่อน

      Wonderful! I felt that way when reading the fasterthanli.me article, I based the video one!
      Here's my short playlist of the best rust features, and how I recommend learning it: th-cam.com/video/oY0XwMOSzq4/w-d-xo.html

  • @shadowreaperjb
    @shadowreaperjb ปีที่แล้ว +2

    this is interesting and makes me want to start trying to learn Rust, but for the sake of comedy,
    Rust's such an unintuitive language that the compiler needs to tell you how badly you f***ed up

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      You should! Its a really interesting language that makes me a better python developer for sure! Try Rustlings, its a fantastic code kata teaching system!

  • @vullkani
    @vullkani 27 วันที่ผ่านมา

    I am an absolute begginer into coding, I've started with Python, but than I looked into Rust and your videos are compelling me to learn Rust first. I watched your other video, I started reading the book, but it seems it is not for absolute beginners. I wish you had a course for someone like me with adhd who wants to start with code at 35 years of age.

  • @polares8187
    @polares8187 ปีที่แล้ว +1

    I love your videos every time

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Thank you so much, I really enjoy making them!

    • @polares8187
      @polares8187 ปีที่แล้ว +1

      @@NoBoilerplate you are the reason why I started my journey with rust and now I am doing advent of code with rust. You are literally changing lives ❤️ World is a better place because you exist ❤️

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      @@polares8187 Thank you so much!

  • @gkvikram
    @gkvikram ปีที่แล้ว +1

    Whats your opinion on natural intuitive value on designing distributed concurrent systems when we are forced to choose between rust on one aile(or C++n java on the same aile)and functional programming languages like Haskell,scala on the other side

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Don't forget Go - though I think Rust is better than Go, go is still extremely good (though it has a GC, no macros, and no super powers).
      I'd say Rust has a lot of functional flavour built-in - the original compiler was writtin in ocaml, and even at one point had an functional purity system, though it was removed, as the Result passing convention works so well.
      You can see the functional influence in both the iterator system, and the monads `Result` and `Option` which are foundational to the Rust standard library and ecosystem.

  • @dragon_pi
    @dragon_pi ปีที่แล้ว +16

    error: Ferris cannot be used as an identifier
    let 🦀 = "";
    | ^^ help: try using their name instead: `ferris`
    ^ this is an actual compiler error

  • @noomade
    @noomade ปีที่แล้ว +1

    Is the rust compiler most advanced than the Haskell compiler? There some pretty impressive stuff that is happening GHC!

  • @axa993
    @axa993 ปีที่แล้ว +1

    Well this looks really impressive

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      You've not seen anything yet - check out my other rust videos!

  • @ex0ja
    @ex0ja 9 หลายเดือนก่อน +1

    As a beginner I do feel like rust is the easiest language I've tried so far, mainly because of the way cargo works and the errors.

    • @NoBoilerplate
      @NoBoilerplate  9 หลายเดือนก่อน +1

      This is a very heartening take - I've got plans for a series of videos about how to go from zero to rust, without learning any other languages first. And it's for this exact reason - Rust helps you SO much at the start!

    • @ex0ja
      @ex0ja 9 หลายเดือนก่อน +2

      @@NoBoilerplate I'd greatly appreciate that as that's what I'm doing!

    • @NoBoilerplate
      @NoBoilerplate  9 หลายเดือนก่อน +1

      @@ex0ja It might be a few months before I get to it, however make sure you've seen my 'getting started' video for now, I've got my learning recommendations there: th-cam.com/video/2hXNd6x9sZs/w-d-xo.html

    • @ex0ja
      @ex0ja 9 หลายเดือนก่อน

      @@NoBoilerplate yes I have and I'm following your advice, I've just finished Ultralearning yesterday ☺️

  • @modolief
    @modolief ปีที่แล้ว +1

    No Boilerplate: Can you provide a link to Rustlings in the video description?

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Good idea! Will do. It's here too github.com/rust-lang/rustlings
      I was teaching a class rustlings at work just yesterday and it's SO GREAT for sparking disussion - I learn much every time I take a class!

  • @chronosVR.2763
    @chronosVR.2763 ปีที่แล้ว +1

    i like compilers like this

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Me too. Haskell's pretty great too

  • @caiosym3009
    @caiosym3009 ปีที่แล้ว +1

    Just found your channel and really appreciate the video's structure!
    Quick errata, but on 6:58, thats not exactly what we did. We fixed the functions return type, not the type of the argument being passed to it or the argument's type itself.
    Kindly,

  • @user-qr4jf4tv2x
    @user-qr4jf4tv2x 10 หลายเดือนก่อน

    i hope to see more of "Rust Is Easy" with dealing with errors

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      Already gotcha covered th-cam.com/video/bu_gulee89Q/w-d-xo.html
      Do check out my other videos!

    • @user-qr4jf4tv2x
      @user-qr4jf4tv2x 10 หลายเดือนก่อน

      @@NoBoilerplate nice thank you

  • @FryuniGamer
    @FryuniGamer ปีที่แล้ว +2

    Rust doesn't guarantee that there are no memory leaks on any piece of code.
    Leaking memory is entirely safe.
    You can make a cycle of Rc/Arc
    You can Box::leak
    You can Box::into_raw and never get the box again
    You can mem::forget something that holds any smart pointer
    All of those are entirely safe operations. It was never the goal of Rust's model to ensure that there are no memory leaks.

  • @Teflora
    @Teflora ปีที่แล้ว +1

    I've been playing around with Rust but there's always a point where I run into a compiler error and it can't help me.
    For example, I needed to edit two elements of an array at the same time. Actually, not the element itself but some sub-variable of them.
    I couldn't do it, bc of course I can't borrow 2 elements of an array. But I haven't found a solution and I went away for a while. Until I randomly stumbled upon it on TH-cam with the name smart pointers. And well, they can become quite complex if you don't know them well. So that's where I'm stuck on currently, learning different types of smart pointers and no the compiler doesn't teach me this sadly.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      That sounds tough, but you'll get there I bet!
      The exciting thing is that the rust language is rich enough that it is possible to improve the errors so much that they'll eventually start suggesting smart pointers!

    • @KohuGaly
      @KohuGaly ปีที่แล้ว +2

      There are ways to mutably borrow multiple elements form the same slice. This is safe, as long as the elements are distinct.
      Here's a function that borrows two elements from a slice, or gives an error if indices are equal:
      fn get_mut_two(source: &mut [T], a: usize, b: usize) -> Result
      {
      match a.cmp(&b) {
      std::cmp::Ordering::Equal => return Err(()),
      std::cmp::Ordering::Less => {
      let (beggining, rest) = source.split_at_mut(b);
      Ok((&mut beggining[a], &mut rest[b]))
      },
      std::cmp::Ordering::Greater => {
      let (b,a) = get_mut_two(source, b, a)?;
      Ok((a,b))
      },
      }
      }
      And here's a version that borrows arbitrary N elements from a slice. Though the implementation uses unsafe, and has expensive runtime checks, that are unlikely to be optimized.
      fn get_mut_n(source: &mut [T], indeces: [usize;N]) -> Result
      {
      // check for index out of bounds
      if indeces.iter().any(|&i| i>=source.len()) {
      return Err(())
      }
      /// check for duplicate indices
      let mut sorted_indices = indeces;
      sorted_indices.sort_unstable();
      if sorted_indices.windows(2).any(|w| w[0]==w[1]) {
      return Err(())
      }
      // SAFETY
      // indices are all distinct and in bounds
      unsafe {
      Ok(indeces.map(|i| &mut *source.as_mut_ptr().add(i)))
      }
      }

  • @darrionsanchez1940
    @darrionsanchez1940 ปีที่แล้ว +4

    True.

  • @IvanArdillo
    @IvanArdillo ปีที่แล้ว +1

    I'm a C# developer and you are making me feel I need Rust. I don't know I could use it on my daily job or for doing some side project. Do you have any advice? I do consultancy, so the well known webapp/database stuff for companies

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      I'd say start with either backend web development with rocket.rs, or frontend web development with yew.rs, depending on your experience and interest.
      Some more of my advice is in this video, if you've not seen it: th-cam.com/video/4dvf6kM70qM/w-d-xo.html
      And how to learn rust is in the latest video here th-cam.com/video/2hXNd6x9sZs/w-d-xo.html
      Come talk to me on my discord, over in #newbie-advice, links in the description, Good luck! :-)

    • @IvanArdillo
      @IvanArdillo ปีที่แล้ว

      @@NoBoilerplate 🙏🙏🙏

    • @IvanArdillo
      @IvanArdillo ปีที่แล้ว

      @@NoBoilerplate 🙏🙏🙏

  • @steffahn
    @steffahn ปีที่แล้ว +1

    Missed opportunity: Follow up by using clippy to make this code more idiomatic. Doesn’t give too much in this particular case, but clippy certainly “teaches” some things really well, too.
    (It doesn’t help you go all the way in this case; arguably, the argument type of this function should become `&str`, and there’s no compiler or `clippy` telling you, AFAICT.)

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Very correct! I was ignoring a lot of clippy errors during my testing here, in order to get the most bare-bones rust experience, for newbies.
      I love clippy, and run it with those and many other options inside a `bacon` session, alongside my ide!

    • @steffahn
      @steffahn ปีที่แล้ว

      @@NoBoilerplate Yes, `bacon` is indeed very useful.

  • @catbb
    @catbb ปีที่แล้ว +1

    will do rust for sure on my wasm project. so i could interact module through flutter. 🦀
    Q : is there any difference between standalone wasm modules created by assemblyscript / emscripten and rust wasm modules ?

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      Great question, sorry I don't know the answer.
      Come ask that exact question on my discord in #programming and you'll get a lot of good answers.

  • @jaroslavhuss7813
    @jaroslavhuss7813 ปีที่แล้ว +3

    If there is a Rust's mascot, it should be Tris, not the crab :) God I love these videos.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      I'm more of a cheerleader XD

  • @yondaime500
    @yondaime500 ปีที่แล้ว +1

    I love how some people say it's a bad thing that Rust does all that, and that "real programmers" don't need it. It's hilarious.
    Rust also makes it really easy to define and enforce quality standards in your project.
    In your lib file:
    #![forbid(unsafe_code)]
    #![warn(missing_docs)]
    #![warn(clippy::unwrap_used)]
    #![warn(clippy::todo)]
    #![warn(clippy::panic)]
    Then in your CI:
    cargo fmt --check --verbose
    cargo clippy -- -D warnings
    You can add plenty of other lints (rust-analyzer gives you a list with explanations on what each one does when you start typing). The warn level lets developers take some shortcuts while working with the code locally, but reminds them to clean everything up before pushing. And the pipeline ensures that code doesn't get merged until it's basically flawless.
    There's also cargo-deny, which searches your dependencies for known vulnerabilities and incompatible licenses. And probably many other tools I don't even know about yet.

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว

      I dig this a LOT. Have you seen no-panic, a macro that forces the compiler to prove that no execution paths could panic? crates.io/crates/no-panic

    • @yondaime500
      @yondaime500 ปีที่แล้ว +1

      @@NoBoilerplate I saw it on one of your previous videos, but I haven't tried it yet. I imagine it gets hard to use when you have lots of dependencies, since most of them do not guarantee that there are no panics, and often you have to turn on optimizations for the panics to be optimized out.
      I kind of wish there was a keyword for that in the language itself, like unsafe but the other way around ("extra_safe"? IDK), so it would get checked at compile time rather than link time, and maybe more crates would adopt it. But maybe an attribute that keeps you from using basic arithmetic operators on integers or clamp() on floats would be so annoying that no one would bother with it. Who knows...

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      ​@@yondaime500 Yeah, we have to draw the line somewhere, for me in normal code I use checked maths and never .unwrap() (enforced with clippy) and then don't worry about oom panics or other rare stuff.

  • @JulienLucca
    @JulienLucca ปีที่แล้ว +2

    After a few years using it and a week or so using both, I feel like Elm's compiler is WAY better. Rust is the second best!

    • @NoBoilerplate
      @NoBoilerplate  ปีที่แล้ว +1

      Fun! Could you elaborate?

    • @JulienLucca
      @JulienLucca ปีที่แล้ว +1

      @@NoBoilerplate Sure! I mean, it's a TH-cam comment. But on Elm the error messages are even less cryptic. The video shows how to follow the compiler helps us find the solutions to the compilation errors. But on Elm it's spot on!
      I ran into an unexpected symbol:
      27| type alias Model = Int | String
      ^
      I was not expecting to see a | here. Try deleting it? Maybe I can give a better
      hint from there?
      Some other:
      Something is off with the body of the `init` definition:
      32| ""
      ^^
      The body is a string of type:
      String
      But the type annotation on `init` says it should be:
      Model
      LAST EXAMPLE, Check it out
      This `case` does not have branches for all possibilities:
      46|> case msg of
      47|> Increment ->
      48|> model + 1
      49|>
      50|> Decrement ->
      51|> model - 1
      Missing possibilities include:
      SomethingElse
      I would have to crash if I saw one of those. Add branches for them!
      Hint: If you want to write the code for each branch later, use `Debug.todo` as a
      placeholder. Read for more
      guidance on this workflow.
      You can just elm-lang.org/examples/buttons
      and fiddle around making compilation fail somehow by experimenting. Its more straightforward

    • @JulienLucca
      @JulienLucca ปีที่แล้ว +1

      and that being said, both are very different, Elm is for a very narrow context: web applications. Rust is way more flexible. Having working a lot with Elm, I do think it's similar to how Rust works in some areas like error handling. Compiler messages are just friendlier and easier to read

  • @caseykawamura8718
    @caseykawamura8718 10 หลายเดือนก่อน +1

    I’m curious how well you could prompt chat gpt with the rust compiler. Might be a good AI automation language.

  • @hunhowshadow317
    @hunhowshadow317 ปีที่แล้ว +1

    When Linus Torvalds rejects Rust for the linux kernel