The Rust Borrow Checker - A Deep Dive - Nell Shamrell-Harrington, Microsoft

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

Комментарии • 25

  • @joelmontesdeoca6572
    @joelmontesdeoca6572 3 года назад +10

    We need more speakers like Nell!

  • @rodelias9378
    @rodelias9378 3 года назад +8

    Thanks for such an amazing talk, Nell. Well done!

  • @therselman
    @therselman 3 года назад +10

    Excellent, you covered a huge amount of information in 22 minutes. And kept it very concise. Amazing job!

  • @ericmink
    @ericmink 3 года назад +8

    That talk was well-made, but I expected more speed and depth from the "a deep dive" in the headline.

    • @primingdotdev
      @primingdotdev 2 года назад

      ruclips.net/video/68U8ZZ1EnEQ/видео.html, this one was useful

  • @HumanoidTyphoon91
    @HumanoidTyphoon91 9 месяцев назад +1

    The talk was interesting and I learned some things, so thank you, but my level of understanding of the borrow checker... that has changed an extremely small amount.

  • @dandogamer
    @dandogamer День назад

    Felt like i learnt some things about the compiler but not so much about the borrow checker

  • @francopan
    @francopan Год назад

    Wow. Just wow. What an awesome presentation!

  • @seanlestermiranda
    @seanlestermiranda 2 года назад +1

    This is amazing, Nell.

  • @muadrico
    @muadrico 4 месяца назад

    To me, it doesn't look very different to what you need to know about scopes in C++. The only benefit of rust is, that the compiler tells you, where you made an error, whereas in C++, you usually need a sanitizer for that purpose.

  • @NFLStudy
    @NFLStudy 2 года назад

    Great video on borrow checker. Thank you Nell!

  • @glennedgar5057
    @glennedgar5057 3 года назад +1

    Good presentation. When is rustc used instead of c# at microsoft

  • @michaelzap8528
    @michaelzap8528 Год назад

    Very important talk

  • @akshay-kumar-007
    @akshay-kumar-007 4 месяца назад

    Is it just me or the video at 16:15 is completely broken?

  • @kbaeve
    @kbaeve 2 года назад

    Thank you!

  • @caseyyeow1649
    @caseyyeow1649 2 года назад

    Excellent! I thank you too!

  • @gregoryking2664
    @gregoryking2664 3 года назад

    This was a very clear explanation. Thank you.

  • @michalkupczyk7
    @michalkupczyk7 3 года назад

    So when I see Rust "let y=x;" for heap-allocated types, it translates to 'C'(C#, C++) code "y=x; x=null; " ??? The x pointer 'loses' the value, and compiler detects use of that?

    • @urbex9797
      @urbex9797 2 года назад +1

      No, that's what happens with a C++ move (the "moved from value" needs to be left in a valid state). In Rust, the compiler doesn't have to use x=null;, because it throws a compilation error instead. Think of it as marking the value as "invalid from that point on" in the symbol table of the function (the symbol table is simply a list of a function's variables that the compiler keeps at compile time).

    • @Rogueixpresents
      @Rogueixpresents Год назад

      this is Rust not c, u need to learn rust not c, u will never use c, so stop being pretentious and just use modern stack.

  • @KevinInPhoenix
    @KevinInPhoenix 2 года назад +1

    On what planet is an assignment statement (let y = x) a "move" instead of a "copy"? In Rust if x and y are numbers then things work as expected. If they are strings then they don't. Rust has eliminated the memory management from the runtime and moved it into the programmers head. Not a reasonable tradeoff for most programming. I would rather be thinking about the problem domain than the rules of Rust.

    • @dv_xl
      @dv_xl Год назад +3

      Compared to a GC language it forces the programmer to think a lot more sure. However compared to other manually managed memory languages it's simply forcing the programmer into constraints that mean a whole class of very common errors are eliminated.
      Allowing stack allocatable types like i32s to copy by default is fine, but creating a copy of a type that contains a pointer to raw heap isn't - within the constraints of rust's memory management

    • @megumin4625
      @megumin4625 Год назад +4

      You need to understand why this happens. Rust is helping the programmer manage memory correctly, rather than letting them make memory mistakes which create UB and vulnerabilities. Even if you did this in another language (say C) and it allowed you to do it, it would cause potential unseen and dangerous UB (and you may not even know about it until years down the road).
      Copying a number on the stack to another variable is fine. It's a cheap copy, there are no memory vulnerabilities associated with this. However, what happens if you instead copy a heap allocated type instead of move it? You now have 2 variables that own it, and now you will free it twice. Oops. Now you just did a double free.
      These are constraints you'd have to fix under any other manual memory management in the first place. The tradeoff exists in any other manual memory management language - the only fact is that it doesn't usually tell you about the problem. Rust just helps you catch it from the get-go.
      However, if what you're worried about is memory management and runtime, many other GC languages exist you can use, e.g. Go. There's a performance cost to using it of course. Rust wasn't designed to have a GC - it was designed to have zero-cost memory management just as fast as c/cpp - but not at the cost of accidentally getting it wrong. To get this speed, the tradeoff is that you have to think about these things. But thankfully, since Rust helps with the memory management, you won't have to get it wrong quite as often. So, if your need was a language that manages memory for you, you're looking in the wrong place, since Rust is more of a c/cpp replacement, not a Python/Java/etc replacement.

  • @kevinkkirimii
    @kevinkkirimii Год назад

    I still hear dungeons and dragons far inside her voice.