Python dev writes bad Rust (still compiles though)

Поделиться
HTML-код
  • Опубликовано: 2 мар 2024
  • Let me explain mny new Rust love affair..
    Join the Discord to discuss all things Python and Web with our growing community! / discord
    If you are new, welcome! I am John, a self taught Python developer working in the web and data space. I specialize in data extraction and JSON web API's both server and client. If you like programming and web content as much as I do, you can subscribe for weekly content.
    :: Links ::
    My Patrons Really keep the channel alive, and get extra content / johnwatsonrooney (NEW free tier)
    Recommender Scraper API www.scrapingbee.com?fpr=jhnwr
    I Host almost all my stuff on Digital Ocean m.do.co/c/c7c90f161ff6
    I rundown of the gear I use to create videos www.amazon.co.uk/shop/johnwat...
    Proxies I recommend nodemaven.com/?a_aid=JohnWats...
    :: Disclaimer ::
    Some/all of the links above are affiliate links. By clicking on these links I receive a small commission should you chose to purchase any services or items.
  • НаукаНаука

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

  • @antoniong4380
    @antoniong4380 3 месяца назад +2

    Maybe personal taste, but I woukd've liked to see the type hinting enabled so I could see what was passed around

    • @kexec.
      @kexec. 3 месяца назад

      yeah mypy is decent

  • @nicoaudy
    @nicoaudy 3 месяца назад +1

    Rust video coming! 🙌

  • @oscarjaramurillo5377
    @oscarjaramurillo5377 3 месяца назад +2

    I think Golang is better designed for scraping due to its simpler syntax, excellent performance, and great tools for network and web development. Rust, on the other hand, seems more like a low-level programming language.

  • @moose304
    @moose304 3 месяца назад

    I've also been trying to learn Rust. I find lifetimes and the borrow checker very challenging. Buuuut....the compiler is just so good and helpful! So by the end, I know if it's compiling, I'm feeling pretty good about the code (even if it's FAR from perfect). Plus I've found the people on the Rust discord server to be nice and welcoming. Enjoy the journey! I'm there with ya!

  • @bakasenpaidesu
    @bakasenpaidesu 3 месяца назад +1

    Finally a Rust video 📹 🙌 👏

  • @pstefan86
    @pstefan86 3 месяца назад

    Though any learning is great - with the promise of Mojo on the horizon, is it not sensible to take no action on learning a lower level language at this point?

  • @davidmurphy563
    @davidmurphy563 3 месяца назад +3

    Ugh, rust looks horrible. Tonnes of boilerplate. No idea what unwrap was. Well, barely an idea of what 90% of it was.
    I guess if you're used to it. And it's fast I think.
    Didn't expect it to be so ugly though...

    • @bakasenpaidesu
      @bakasenpaidesu 3 месяца назад +3

      In Rust, unwrap() extracts the value from Result (OK variant) or Option (Some variant), but triggers a panic with an error message if it encounters an error (Err variant for Result or None variant for Option).

    • @davidmurphy563
      @davidmurphy563 3 месяца назад +1

      @@bakasenpaidesu Um, not sure I get it. Is data held in some object and in order to access the memory you have to call the unwrap method? Or is it like grabbing a dictionary value by key where it throws an error if the key isn't there as opposed to get(). Honestly, I just don't know.
      Do you agree it's ugly? Or do you think I'm being unfairly harsh? I heard it's got a really nice manner of handling memory leaks without needing a garbage collector but I don't know the details. Who knows, maybe it's a pleasure to code when you get into your stride. And fast is good. Plus it's indented, so no curly braces which is a big plus.
      Could be that I'm stuck in my ways and just want everything to be python. :)

    • @themrubios
      @themrubios 3 месяца назад

      ​@@davidmurphy563 >Um, not sure I get it. Is data held in some object and in order to access the memory you have to call the unwrap method?
      No, those methods can fail, so they return a sum type which is Ok (with the value) | Error (with the error details).
      > Do you agree it's ugly?
      Not at all, it's by far the most "beautiful" (whatever that means...) and convenient way to represent error states, I've yet to see a more elegant solution out there and I've tried quite a few (Exceptions, error values without sum types, implicit panicking, etc...)
      >Or do you think I'm being unfairly harsh?
      Being blunt, it just looks like you don't know what you're talking about.
      >Could be that I'm stuck in my ways and just want everything to be python. :)
      Correct Python is a lot more verbose than correct Rust (just imagine each one of those .unwrap() replaced by a several lines long try-catch block with logging and an explicit exit)...
      The big difference is that Python lets you write code that can be proven broken, while Rust doesn't.

    • @davidmurphy563
      @davidmurphy563 3 месяца назад

      @@themrubios "Being blunt, it just looks like you don't know what you're talking about."
      Never pretended to, this is pretty much the first time I've seen the language. I was struck by how ugly it was. I have decades of experience in python but, Rust no clue. The giveaway was that I was asking basic questions. People that you know everything already then you don't ask questions. That's always a clue.
      "Correct Python is a lot more verbose than correct Rust"
      Hahaha! That's genuinely hilarious. I suspect the word "correct" is doing a lot of legwork in that sentence!! Jeez, I dread to think makes for good code...
      You're funny.

    • @themrubios
      @themrubios 3 месяца назад

      @@davidmurphy563 >I suspect the word "correct" is doing a lot of legwork in that sentence!
      Correct as "It cannot fail in any unexpected and/or not-explicitly-handled way".
      The Python interpreter will happily let you throw errors at any point (including in code that is not yours to begin with) that may or might not be handled in a completely arbitrary way, hell, it will happily let you dereference stuff that _it knows_ doesn't exist.
      ... and that's OK for code that doesn't matter, when the consequences are _some web service is down, let kubernetes reset it_ that might be just fine, but Rust is meant to power all kinds of software, including ones where "oopsies" imply people dying. It just happens to also be a great option for senior people (who already think about stuff like explicit error handling or ownership when writing any other language) to build web stuff.
      If you only care about building web stuff as fast as possible regardless of anything else, Rust is simply not for you.

  • @josealejandro7382
    @josealejandro7382 3 месяца назад +1

    Rust is Amazing!!!