Implementing (part of) a BitTorrent client in Rust

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

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

  • @MasterHigure
    @MasterHigure Год назад +51

    I think this is the first time I've stopped one of your videos and started actually doing it myself, rather than sitting passively and taking it in. The moment you started doing lists I just felt that this was I problem I needed to try to tackle on my own before seeing someone else do it.

    • @jonhoo
      @jonhoo  Год назад +20

      It's fun isn't it! :p

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

      @@jonhoo Gjett'a ^^ I listened to you discussing why it's not trivial to find the right 'e', and my mind started racing. I just reached that point myself in the course, so I'm going to do some chores that I've been putting off, and then I'll get cracking.

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

      You leveled up 👍

  • @albertlie9138
    @albertlie9138 Год назад +150

    I will gladly spend all my time watching you go through every challenge on that site 😂

    • @zeeshanmh215
      @zeeshanmh215 Год назад +5

      This.

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

      Watched the entire thing and i couldn't agree more. Git or SQLite would be a fun one to watch

    • @Bluman124
      @Bluman124 10 месяцев назад

      Yes please they're super interesting. The applied code coupled to reading the different protocols and docs is awesome

  • @KuldeepYadav-jw7jn
    @KuldeepYadav-jw7jn Год назад +55

    This is the kind of programming content, one craves for on youtube! 👏

  • @matts1839
    @matts1839 Год назад +24

    I like the way you write a code and tell what the code syntax means, like "rest, until ..len". I learn Rust syntax and libs much faster than reading their docs. Great stuff!

  • @sergeylypko5817
    @sergeylypko5817 Год назад +5

    Your thought process is highly insightful and engaging to observe. Thanks for great content. And yeah, topic like that are incredibly interesting (live coding of X). I'd be more then happy watching you'r implementing any kind of DB engine, the same stuff as those folks from codecrafters suggest (clone of docker, git etc), browser engine, SQL parser, interpreter or any possible real thing from the fundamental technology we use every day. For example I'm studying Rust, and trying to fill the gaps in my CS knowledge and indeed, building the real things are incredibly powerful approach. And again, watching you doing things, studying your way of thinking and using the language and tools is a real treasure.

  • @MatthewDickensmjd
    @MatthewDickensmjd Год назад +14

    I love the idea of teaching you by building something that already exists. I am definetly considering doing this on my own.

  • @cpetzold
    @cpetzold Год назад +29

    At 2:32:57, you were still passing `t.announce` to `Url::parse` instead of `tracker_url`. That's why it looked like it was stripping off the query params.

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

    I discoverd Codecrafters thanks to your stream. I decided to implement it on my own and only watch your video when I'm absolutely stuck. Funny enough I spent the most time in many of the places where you were such as the issue with json Value not liking the bytes array and then URL encoding these bytes. I hope Codecrafters can improve on this, like maybe do not run the previous steps in their tests and pull in a create for URL encoding for bytes.

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

    Best Rust content on RUclips.
    Please do part 2!

  • @buildyourownx
    @buildyourownx Год назад +9

    Now _that_ was an incredible livestream

  • @cchance
    @cchance Год назад +6

    Please say you plan to continue this your videos and the way you break things down really helps me see alternative ways of doing stuff.. that said I think a quick refactoring of those calls in your main function would have really cleaned stuff up lol

  • @beebakrizzle
    @beebakrizzle Год назад +10

    You might like the "Dark Reader" FF extension ;) awesome content as always!

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

      I wanted to say about the same Dark Reader ext. Here you have already did.

  • @MizardXYT
    @MizardXYT Год назад +8

    For dark mode, you could add a CSS rule: `html,img,video, { filter: invert(1) hue-rotate(180deg) }`
    This inverts the whole page, and then reverts any images back to normal.
    Easy to put in a bookmarklet:
    `javascript:(function(){var s=document.createElement('style');s.innerText='html,img,video,{filter:invert(1) hue-rotate(180deg)}html{background:white}';document.head.appendChild(s)}())`

    • @rafaeldeconde8148
      @rafaeldeconde8148 Год назад +7

      one thing I kept thinking about all the time with the dark mode is, why not use the dark reader extension?
      He's using firefox, I might be missing something but the extension seems to be great.

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

    Please keep doing "impl" rust streams, you are fairly unique in this respect.

  • @not_yet_implemented
    @not_yet_implemented Год назад +2

    Nice, the replay is here! Couldn't be there during the live stream. Good topic.

  • @rsalmei
    @rsalmei Год назад +1

    @jonhoo In 2:46:40, the unsafe cast Handshake as a slice, you've explained that you can do that because of the #[repr(C)]. Ok, but won't that introduce undesired padding, that the C repr would be generating in the memory?

    • @siddharthbisht8522
      @siddharthbisht8522 Год назад +1

      Did you figure it out? I am beginner in C too but my guess is that since all of them have the same alignment (u8) there is no padding/holes in the struct.

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

      @@siddharthbisht8522 I didn't yet, thank you! Yep, perhaps that's it. Even arrays of 19 u8 have no padding?
      But anyway, in case we did have a struct with a u32 for instance, we _would have_ this memory padding problem in case we wanted to output its bytes, right?
      I'm not sure what #[repr(C)] does as well. He says that's why he can treat it as a bytes array in the first instance, but "it's not really what it means directly"...

  • @Heimyto
    @Heimyto Год назад +1

    16:52 -> No, it's not nicer. Before that you had determined that the encoded string starts with 'i', so it doesn't belong to the last branch any longer. Now you can't distinguish between "doesn't start with i" and " it does, but the input is corrupted"

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

    the zero copy trick shown in this video seams very neat but it requires unsafe. I would love a video where you explore this type of optimizations and if/why they are ok and when.

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

    Looking forward to part two, if you make one!

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

    Thank you for such content. It instils nice coding habits of mature engineers to newbies like me.

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

    What shell magic are you using for the typeahead/autocomplete directory name at 4:09? Is that a zfish thing?

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

    At one point you said that the fat pointer to you unsized struct stores the length of the last field, but the pointer to byte slice would contain the length of the entire thing, so I don't think your unsafe cast is valid. Though I would expect it to be off-by-8 not off-by-7. 😅

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

      Yep, that was indeed one of the bugs! See github.com/jonhoo/codecrafters-bittorrent-rust/compare/f71ed3d223acbceaa42fea220f774f9aba8f56c9...HEAD

  • @comradepeter87
    @comradepeter87 Год назад +5

    1:23 That's just sponsorship minus the good part of money 😂

  • @Dorumin
    @Dorumin Год назад +1

    2:25:00 I agree it is pretty stupid, why not #[serde(skip)]?

  • @hmartsocks
    @hmartsocks Год назад +9

    if you don't mind, could you update your dotfiles in your repository? I would like to try out your setup!

    • @jonhoo
      @jonhoo  Год назад +6

      github.com/jonhoo/configs

    • @lbertondev9149
      @lbertondev9149 Год назад +2

      @@jonhoo wow thanks for sharing !!

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

    When I think of a Software Engineer this is what I mean. Not somenone who learns how to use a framework to make a CRUD. I'm in my path to transition from CRUD dev to real engineer (in my conception)

  • @rodelias9378
    @rodelias9378 Год назад +2

    Great stream! Thanks a lot! Looking forward for part 2… 😅

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

    In networking numbers adresses etc. are always in big-endian. The way I remember it is that it's similar to phone numbers. You always start with the numbers that represent large things like a country then a region to small things like a city then a street...

  • @juchemz
    @juchemz Год назад +2

    I'm glad its not just me that's infuriated with crates that aren't configurable enough. I have been trying to use tonic with mutual TLS and they don't provide a way to override the rustls TLS configs except through their builder, which doesn't have what I need. I essentially had to rebuild tonic with tower myself!

  • @longbranchgooberdapple2238
    @longbranchgooberdapple2238 6 месяцев назад

    2:31:47 - it's not cutting off info_hash, you shadowing tracker_url and all it's params by parsing just announce on the next line.

  • @bozhidaratanasov7800
    @bozhidaratanasov7800 Год назад +1

    Hi, have you shared your Neovim config previously?

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

    Great video, looking forward to pt2

  • @ewe-studios
    @ewe-studios 3 месяца назад

    @jonhoo Would be awesome if you did a Decrusting the Bevy engine crate!

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

    Could you please make a video about GenericArray?
    I also encountered it a lot and never took the time to research, why its needed and how to really work with it.

  • @driedurchin
    @driedurchin Год назад +1

    Link to your chair? Would you recommend?

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

    amazing. I was wondering if you could share your nvim dotfiles ?

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

    The next best thing to pairing with an expert!

  • @haydenridd
    @haydenridd 8 месяцев назад

    Just a note here on #[repr(C)], be super careful if you're going to use it like he did (writing bytes directly from/into a struct). #[repr(C)], just means "treat this like a struct in the C language", which means padding/alignment/endianness is totally dependent on the system you're compiling for! "unsafe" is appropriate here, as mismatches in endianness/alignment can lead to behavior that may be "defined" (as he mentions any bit representation of POD is valid), but not what you're intending :)

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

    Do you file bugs in projects when you encounter chaos like the url params stuf?

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

    My favorite part by far is talking out loud while you're tackling a problem you haven't "practiced" before the stream

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

    A wild chaos move appeared! 44:23 😂

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

    I don't understand where the 1

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

      Oh, yeah, you're right, that's entirely a brain fart on my end I think!

  • @11WicToR11
    @11WicToR11 Год назад +1

    love this content, more "real life issues" if you ask me

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

    I kept wondering if the time you put into implementing the tokio codec would be wasted if the platform rejected/ignored your Cargo.toml changes, but the video ended before you ever pushed your changes relying on it 😭

    • @jonhoo
      @jonhoo  Год назад +1

      Oh, you mean the life stream? There was a power outage, but I came back maybe 5-10m later. This video has the whole thing, including after I came back (and did that push)

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

    Very beautiful code.

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

    20:27 - Cat confirmed employed.
    Better be paying a decent wage man, they be hungry out here on a budget 😂😂😂❤

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

    Great content,. Thank you

  • @wanglipeng8130
    @wanglipeng8130 10 месяцев назад

    The last chunk size bug is not trivial to find😂

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

    2:33:20 I really feel your pain!

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

    chaos move!

  • @Ireliar2024
    @Ireliar2024 2 месяца назад

    Yeah, I been stuck in the URL part for a week hahahaha

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

    Great

  • @Onkoe
    @Onkoe Год назад +2

    wooooah, that service is expensive! really makes me want to make my own (much worse) version of it lmao

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

    23:26 you made mistake, it's not "rest" but "rust" 😂

  • @pramodjingade6581
    @pramodjingade6581 Год назад +2

    🫡 Please do more videos like this, Highly insightful !!

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

    Amazing content. I don’t do Rust, but I learnt, learn the fundamentals, language is just a medium . So I follow you and learn a lot.
    I did want to get some career suggestions from you , any chance you on discord or any slack community, and I can reach you over dm. Thanks .