Rust Ownership and Borrowing

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 267

  • @sumechans
    @sumechans 4 роки тому +140

    Not sure why I bought all these tutorials from Udemy, Packt etc, when this amazing tutorial was there free for everyone. Kudos to Doug. You are an amazing instructor.

    • @dougmilford7814
      @dougmilford7814  4 роки тому +16

      Thanks! Just wish you could have saved a few bucks. Oh well.

    • @sumechans
      @sumechans 4 роки тому +3

      @@dougmilford7814 You mentioned on this video, tutorials on arrays, vectors and collections are coming, are they out?

    • @dougmilford7814
      @dougmilford7814  4 роки тому +11

      @@sumechans Sorry... haven't gotten to it yet. Life gets in the way sometimes.

    • @sumechans
      @sumechans 4 роки тому +4

      @@dougmilford7814 Definitely worth waiting. Thanks!

    • @canardeur8390
      @canardeur8390 4 роки тому +2

      @@dougmilford7814
      Timing: sometimes, when we want to start something, the great product for free is not there yet and we have no idea that this great product would come a couple of weeks later.
      Since we do not have the patience, we pay for courses.
      And yes: awesome tutorial and great job. Thanks to you, I now understand why we use references and not the objects themselves.

  • @TheZazatv
    @TheZazatv 7 місяців тому +6

    This is by far the best tutorial on that topic out there. I love that you've included every use case!

  • @yanchaoli551
    @yanchaoli551 5 років тому +134

    best rust tutorial ever, looking forward more stuff coming

    • @dougmilford7814
      @dougmilford7814  5 років тому +17

      Wow, quite the compliment! I'm finishing up Rust 3D Graphics in the Browser right now. Hopefully by the end of the year it'll be out. I needed a break from the bread-and-butter topics to do something a little more fun. After that I'll circle back to some important fundamental topics like concurrency and creating macros. So, yes, more stuff is coming!

    • @anubhav200
      @anubhav200 3 роки тому

      exactly

  • @parthokr
    @parthokr 5 місяців тому +2

    This man has mastered the art of teaching for sure.
    Memory management has never been this easier.

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

    oh my god, never seen this much clear explanation of programming in general. Wonderful

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

    This is the finest tutorial I have ever seen. It's well explained and illustrated with clear examples. Thank you Milford

  • @estupefatos
    @estupefatos 11 місяців тому +2

    He teached me Rust and also how to teach. Thank you, Mr. Milford. You're a legend.

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

    I finally understand this concept! thank you so much!!!!

  • @hamzamohd.zubair1709
    @hamzamohd.zubair1709 3 роки тому +5

    You have mastered Rust as well as the art of teaching

  • @drippedoutlawyer8166
    @drippedoutlawyer8166 4 місяці тому +2

    I finally get how it works thanks to you!

  • @waynelee7320
    @waynelee7320 4 роки тому +6

    I'm a JS programmer. I found this idea of ownership and borrowing is exactly what I need in JS. Copies and Refs are so messed up in JS. It is the best explanation on this topic I've seen and cleaned up a hell lot of mess for me to understand Rust. Thanks!

  • @nathanielwoodbury2692
    @nathanielwoodbury2692 4 роки тому +32

    Holy crap it has never felt so simple. This dude is a teaching master haha

  • @freedoompictures6839
    @freedoompictures6839 4 місяці тому +1

    Concise, to the point, fun to follow and really explains the thing in whole, not bits and parts of it. Your teaching speed is calibrated ideally which makes following the course easy. Finally found a channel to follow learning Rust. Thank you!

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

    This is by far the best Rust tutorial series I’ve ever watched! Excellent work!

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

    Doug this is a great video. I like your sense of humor.

  • @OP-hw4xj
    @OP-hw4xj 2 роки тому +2

    "If you cannot explain it simply enough, you do not understand it well enough", you sir most definitely understand the subject to the minute details! hats off to you for the amazing explanation!

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

    Great tutorial. That is easily the most troubling programming stuff I've learned in years but I think it's growing on me.

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

    All these tutorials in rust are amazing. Your teaching is exceptionally engaging, clear and organized. You are an amazing and wonderful teacher . Thank you very much for teaching. Much appreciated.

  • @danvilela
    @danvilela 4 роки тому +20

    I am amazed with how can they build this kind of compiler

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

    so far this is the best and crystal clear explanation for rust ownership and borrowing video that I had watched. appreciate for the hard work.

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

    Wow!
    Lucky to run onto your tutorial, it makes a lot of sense compared to other Rust tutorials, great job!
    As a python/js developer with some knowledge of c/cpp I find that Rust combines both worlds in a unique way which somehow makes more sense than traditional concepts.

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

    Where before I was hesitant to learn Rust because of it's high learning curve, now I am emboldened to learn it because you explain it so clearly. Thank you. Glad I stumbled upon your channel.

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

    Mind blowing 🤯! Thank you for video.

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

    Very fine and well created material. Concise, straight to the point, and easy to understand. Well done, sir. Well done.

  • @marcelijankowski9593
    @marcelijankowski9593 6 місяців тому +1

    In my new job Im being transfered to a Rust project, this video was really helpful, thanks!

  • @WouterStudioHD
    @WouterStudioHD 4 роки тому +7

    Rust is brilliant. I have quite some experience with C++ and I can totally see that Rust is just so much better. It's so explicit, consistent and well defined, while still being just as fast if not faster. I don't even know if I can bring up the motivation to write one more line of C++... Thank you for this clear explanation.

    • @dougmilford7814
      @dougmilford7814  4 роки тому +3

      Couldn't agree more!

    • @-taz-
      @-taz- 4 роки тому +3

      Some languages are bringing back functional ideas that are older than computer science, even. Some try to clean up C++ like D and Go, or clean up Java like Kotlin. They usually remove or minimize inheritance, and maximize immutability. But Rust is the only one trying fundamentally new ideas. I've used C++ for 27 years, and I'm having a hard time with lifetime management in Rust -- the notations. Pattern matching is what lured me in, because I tried for years to do that well in C++, and I did alright, but then try getting some random C++ coworkers interested in algebraic types and overload sets. Good luck! I gave up. C++23 will probably get pattern matching, but lifetimes? Nope. Plus std::optional, std::any, and std::variant are a hodgepodge, and std::expected is still just a proposal.

  • @stphane
    @stphane 4 роки тому +1

    Thank you for such a clear and exhaustive overview on Ownership and Borrowing concepts.
    Such free contents have no price and there should be as much "thank you" comments as there are thumbs-up on this video.

  • @cerex1273
    @cerex1273 4 роки тому +3

    I got the concept reading the official rust book but your clean explanation with examples is true gold. I'm sure you spent much time creating this tutorial with passion so you deserve all my gratitude for your hard work. Thanks so much :)

    • @dougmilford7814
      @dougmilford7814  4 роки тому +6

      Ah, thank you! Yeah, these videos are much more work intensive than they appear.
      This topic I spent quite some time trying to figure out how to describe it to others without confusing them more. I'm just so glad it seemed to come out well and the viewers are finding it so useful :)

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

    Been working my way through the Book and have struggled with the ideas of ownership and borrowing. This video has really helped my understanding so thank you! I will definitely have to check out your others

  • @sudhir1274
    @sudhir1274 4 роки тому +2

    The explanation of ownership and borrowing is very well explained in this tutorial. A lot of misunderstandings and misconceptions in Rust have been cleared up by viewing this tutorial. This concept is not very well explained in any other literature or tutorial. I really appreciate this whole series. One of the best tutorials on Rust in my humble opinion. I have viewed others and none are as clear and concise as this one. Thank you once again.

    • @dougmilford7814
      @dougmilford7814  4 роки тому +1

      I truly appreciate all of the positive feedback! I don't make any money from these videos, so having others enjoy and learn from them makes me happy that I could help others learn Rust. It makes my day when I get feedback like this :)

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

    One of the best Rust tutorial series I have come across. Thanks for sharing!!

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

    Best tutorials on rust ownership and borrowing i've seen so far....the humor made it easier too 😊

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

    This is an amazing video! Thanks for helping me understand memory management in Rust better. I'm working on my own video series on Rust, that's currently available on my channel, but I haven't covered borrowing and memory management yet. Keep up the great work, Doug!

  • @rahulek914
    @rahulek914 5 років тому +6

    Very good coverage of seemingly difficult concepts. Your efforts are experienced through easy to understand samples. I suggest the topic of covering the standard library as much as you can. Thanks.

    • @dougmilford7814
      @dougmilford7814  5 років тому +2

      Thanks :) I appreciate the feedback. I'm currently polishing up a mini-series on doing 3D Graphics in the browser with Rust, and it should be out in the next few days. I needed to tackle something fun, but I'll be able to get back to the bread-and-butter topics (including the standard library) by next week. There's so many topics I want to cover, and only so much time. It's motivating to get messages like yours, though.

  • @keeganspeck
    @keeganspeck 4 роки тому +1

    I don't often comment on videos, but I've watched about a dozen today on the concept of ownership/borrowing/references in Rust and yours was *by far* (and I really mean *by far*) the clearest and most effective lesson I've seen on the topic. Kudos and thanks. Seriously.

  • @joaoguilhermejarochinskima1820
    @joaoguilhermejarochinskima1820 4 роки тому +2

    A true hidden gem on youtube

  • @nickschmitt8594
    @nickschmitt8594 4 роки тому +1

    26:10 putting var_a.push('a'); after var_b and var_c.... awesome explanation!! thank you!!

  • @KiffinGish
    @KiffinGish 4 роки тому +1

    This has to be the best explanation of ownership that I've ever seen ... it now is all suddenly making a lot of sense!

    • @dougmilford7814
      @dougmilford7814  4 роки тому +1

      Hey, great! Yeah, tricky topic. Took me some time to wrap my head around it, too. I think it takes everyone a bit of time. Glad it's starting to click for ya :)

    • @KiffinGish
      @KiffinGish 4 роки тому +1

      @@dougmilford7814 Your approach by handling the heap and stack separately is what helped me get a better grip on this tricky subject.

  • @williamb.2031
    @williamb.2031 4 роки тому +13

    Awesome tutorial as always! Love how your commentary has a perfect mix of technical with a hint of goofy. Always makes them fun to watch. You briefly touched on functional programming, seeing some functional programming related tutorials in Rust would be fantastic :)

    • @dougmilford7814
      @dougmilford7814  4 роки тому +8

      This is the second request I've had regarding functional programming I had in a week. I'll go ahead and move it up the list. Thanks for watching!

  • @avatar098
    @avatar098 4 роки тому +3

    Went on the journey to create a game entirely with Rust! Ran into your video and it totally helped me understand this!

  • @fbytgeek
    @fbytgeek 4 роки тому +2

    Subscribed after watching just one video!! Content is of quality! Thanks a lot for your efforts! Please continue creating more content as time and circumstances permit.

  • @ClabirdDoudou
    @ClabirdDoudou 4 роки тому +6

    Thank you very much ! The quality of all your Rust tutorials is amazing.

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

    thank u ser, this is the best video on rust ownership and borrowing on the entire youtube

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

    wow! After watchin this video, the stuff with ownership and borrowing seems pretty straightforward. Thanks!

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

    Love the enthusiasm you bring to these videos! It's really reassuring to hear you explain things as a newcomer might experience it:
    "What the ding-dong is that??" -- me, in the future (probably)

  • @LinuxForLife
    @LinuxForLife 4 роки тому +4

    The best video I have ever seen about this topic! Thank you.

  • @andermetalbrasil
    @andermetalbrasil 4 роки тому +2

    Your videos are very well explained. I'm just a beginner hobbyist programmer trying to learn the Rust language, and your videos surely are a great help. My only experience with programming is a little of GDScript, the scripting language used in Godot game engine. I'm studying Rust for about only two weeks, reading the The Rust Language Book from the official website and watching some videos about the language, and I think I'm starting to understand how borrowing and ownership works, but I'll have to practice it a lot to make it natural to me. When I think I'm ready I'll try to make a game in Rust.
    Thanks for your work teaching this amazing language.

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

    Thanks very much it really helped me understand the craziness behind the hood of borrowing and ownership!

  • @indrajitbanerjee4350
    @indrajitbanerjee4350 4 роки тому +2

    Wow rust's memory management is kind of revolutionary. It feels almost unbelievable that we came this far in programming languages and took us this long to figure out the fact that it is indeed possible to define rules of a language that doesn't permit most memory issues in the first place without a runtime garbage collection. Kind of makes the subject of garbage collector moot doesn't it?
    C++ does a good job despite being backward compatible with C. The only issue is C++'s solutions are library features mostly and can't come close to the rust's features that have much deeper ties with the language and the compiler

    • @dougmilford7814
      @dougmilford7814  4 роки тому +1

      Yeah, Rust really re-thought the rules and came up with something groundbreaking. That took real courage.

  • @pshar2931
    @pshar2931 5 років тому +5

    Very helpful. Thanks for taking time to create such videos. I liked the way you represented the concept.

    • @dougmilford7814
      @dougmilford7814  5 років тому +3

      Hey, thanks for the compliment! I appreciate it :)

  • @myhendry
    @myhendry 4 роки тому +2

    Gosh! Can i give 2 thumbs up?? Amazing video on Rust!!!! TQ very much Doug

    • @dougmilford7814
      @dougmilford7814  4 роки тому +2

      I live for comments like these! I really appreciate it :)

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

    These tutorials are like a GEM. Thank you very much

  • @peperudpeperudski1911
    @peperudpeperudski1911 4 роки тому +1

    Best explanation I’ve heard. Can’t say I care much for the web assembly gymnastics at the moment, but I really hope to hear your take on threading, async io and other features that make a language “complete”.

  • @MrPetzold123
    @MrPetzold123 4 роки тому +3

    Best explanation of ownership and borrowing I've seen, thanks ! I'm sure this will help when "negotiating" with borrow checker next time :-).

  • @dkarlovi
    @dkarlovi 4 роки тому +3

    Excellent explanation, it finally made it click for me! Thank you very much!

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

    Really great tutorial, way more clear than anything else I've come across

  • @sylver76
    @sylver76 3 роки тому +1

    Thanks! This clears thing up a lot.

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

    This was such a helpful video. I feel like I actually understand ownership and borrowing in Rust now. Thanks Doug!

  • @pheonex4180
    @pheonex4180 4 роки тому +2

    Thank you so much for your Rust tutorials. They have been extremely valuable and definitely the best I've found.

  • @Utubewonderful
    @Utubewonderful 5 років тому +1

    Very clearly explained this topic. Since past 1 month I'm learning rust, your videos shows how much i missed. Please add more in-depth videos and mini-projects with those concepts. Thanks ;)

    • @dougmilford7814
      @dougmilford7814  4 роки тому +1

      I saw this message that you wrote. I know it's a little late, but I've published a few more videos. I'm currently considering doing a video on "Macros". Let me know if you'd be interested in that.

  • @Barskest
    @Barskest 4 роки тому +9

    You mention in the video that functional programming is the way to go. I've been trying to find information about it with moderate amounts of luck, could you possibly make an introductory video explainign some of the concepts with simple examples as you do with the topic of ownership in this video? :)

  • @_myron
    @_myron 4 роки тому +5

    Great tutorial Doug, can't wait for the parallel programming guide!

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

    Ownership... what the ding dong is that?!
    But for real, great presentation. This was really clearly explained. Glad I found this channel

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

    This channel is underrated!

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

    I finally understand ownership and borrowing, thank you!

  • @shahbaazin
    @shahbaazin 3 роки тому +1

    My organisation doesnt have this video, Thanks Rust Angel

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

    This is the type of thing that old-type C++ programmers used to do. Everyone was expected to know it, even high-level Application developers creating User Interfaces. The exception were the BASIC programmers, which is why VB became so popular

  • @nickssmirkingrevenge
    @nickssmirkingrevenge 4 роки тому +3

    Great job! You explain everything so clearly and in a really engaging manner. Thank you!

  • @chiwbaka
    @chiwbaka 3 роки тому +1

    This guy speaks directly into my brain. It's like learning in the Matrix.

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

    what a hidden gem. thank you so much for an amazing tutorial

  • @santerek28
    @santerek28 4 роки тому +3

    really amazing ! kind of myth busting on Rust ! Thanks Doug !

  • @mageprometheus
    @mageprometheus 4 роки тому +2

    Perfect clarity of concept. Thank you.

  • @PoisonAlienful
    @PoisonAlienful 4 роки тому +1

    THIS. IS. THE. BEST. TUTORIAL. EVER.

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

    This is amazing content. But 30:41 why Rust will think so ? Struct can have thousand fields ..! Compiler will check the struct too right?? Can anybody explain?

    • @harrypotil860
      @harrypotil860 9 місяців тому

      I got to know that it’s nothing to do with thousands of fields. By default struct doesn’t implement copy and that’s it. You should either implement COPY or reference.

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

    Jupp. The best video on this. Thanks Doug!

  • @igorkuchin9302
    @igorkuchin9302 4 роки тому +2

    Thank you very much! This makes ownership and borrowing quite clear.

  • @philipjin7572
    @philipjin7572 4 роки тому +2

    Thanks Doug , a very good video to explain rust key function!

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

    Fantastic video Doug and your style is quite funny.

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

    "Nobody makes the first jump" love it

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

    37:22 "Rust deals with stack variables different than heap" But that's contradicting what you said at 30:05: "Because DougsStruct is composed entirely of stack variables...". It's probably more accurate to say that Rust deals with stack PRIMITIVES differently than heap primitives (are Strings primitives?) and non-primitives? I think I follow though, and it's a very helpful video!
    One question I have: what would it look like for an instance member function to return a mutable reference to one of its instance members?

  • @sheikhakbar2067
    @sheikhakbar2067 3 роки тому +1

    Best Rust tutorial on ownership! Watch it twice if you have to!

  • @idiot7leon
    @idiot7leon 4 роки тому +2

    Thanks! Very clear explanation, and fun lecturing! I enjoy it very much~

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

    Everything you can name is allocated itself on the stack …. That parts of that object is stored in the heap or if it acts as proxy to something that is in the heap does not change that fact.
    Understanding this has helped my team members grasp this whole complexity better.

  • @omerozdemir1395
    @omerozdemir1395 4 роки тому +1

    what the... you are explaining so well the ownership that it becomes easy as 2 + 2

  • @JamesColeUk
    @JamesColeUk 4 роки тому +4

    This is a very clear explanation. Great job!

  • @pinch-of-salt
    @pinch-of-salt 3 роки тому +2

    Love your rustlang videos! 8:41 you said String can't be allocated on stack, I think you can allocate &str on stack. I know they aren't the same thing.

  • @sudhir1274
    @sudhir1274 4 роки тому +1

    Another very good tutorial. I was struggling to under this concept. Very well explained.

    • @dougmilford7814
      @dougmilford7814  4 роки тому +1

      This video is my favorite as it really dives into the heart of Rust and it's idiosyncrasies. I'm so glad you and others have found it to be useful.

  • @joculator9820
    @joculator9820 3 роки тому +1

    Great video sir - informative and enjoyable. Thanks

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

    This is great, and needs more views!

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

    so good! cant wait to watch more of your Rust content!

  • @lairely
    @lairely 5 років тому +2

    The best video rust tutorial we never had! If you do a course on udemy or others I'll definitely take it.

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

    Respect!!! And thank you for the best explanation on the subject

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

    Fantastic explanation of a difficult topic in Rust. Thanks!

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

    Yeah very good rust explanation. I saw that you implement a webgl based project in the end. I guess you could start a series on webgl for beginners as well.

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

    Wouldn't it be useful to have something in between mutability and immutability; a container that cannot change size but whose values can be replaced?

  • @invisiblian
    @invisiblian 4 роки тому +1

    great tutorial. concise and to the point. many thanks

  • @h1k0usen13
    @h1k0usen13 4 роки тому +1

    These videos seriously deserve more views

    • @dougmilford7814
      @dougmilford7814  4 роки тому +2

      I've noticed a distinct pickup in the last couple of months, so that's good. Maybe UA-cam's algorithms finally picked em up.

  • @Y3arin
    @Y3arin 3 роки тому +1

    That was extremely helpful Doug, thanks!

  • @anuraghazra4772
    @anuraghazra4772 4 роки тому +1

    Amazing video... very clear and concise. and loved the way you teach.

  • @luhem7
    @luhem7 4 роки тому +2

    Thanks for making this entertaining and informative to watch!