Rust can Compete with Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

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

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

    this is exactly the content i am looking for! incredibly well put together, thanks for this mr O'Connor :)

  • @braden-wong
    @braden-wong 3 หลายเดือนก่อน +4

    Been a huge fan ever since you released the tutorial on lifetimes! Please put out more videos, I can't stop watching them!

  • @buensofvida
    @buensofvida 2 หลายเดือนก่อน +1

    brilliant way of presenting the nuts and bolts, thank you 👍

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

    Excellent tutorial! I like that you not only explain how the Rust features work and why they work that way, but you also give examples to show the reasons that they work the way they do. This is the clearest explanation I've seen on the topic.

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

    Before I started using Rust, I thought it was a bit of a cult.
    Well... I'm afraid I've become a cultist...

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

    Just to interject that there is already a pretty decent rust interpreter named evcxr. Nowadays I use it as my bash replacement whenever a script starts to get too complex.

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

      Did not know that. Will be checking it out, thanks!

    • @wassim-akkari
      @wassim-akkari 2 หลายเดือนก่อน

      Yes I use it all the time, it's awesome.

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

    Hey, how did you make these slides? Seems like a great way to explain programming concepts!

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

      Reveal.js :)

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

    great video.

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

    27:00 Rust, like everyone else, does *not* guarantee cleanup code will be called correctly every time. It will in this case (as with any RAII language) but `std::mem::forget`, `Box::leak`, and reference cycles are all possible in safe Rust.

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

      Well yes but you cannot really miss the fact that you called such functions by yourself (or the dev of a lib that you use but a good lib will always handle cleanup) or choose to use a type of ref that allows ref cycles, which can still be cleaned up sooner because you have often clear distinction and restrictions between strong, that clean up resources when all dropped, and weak ref that cannot.

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

      I believe it's also not called on statics either
      Not to say I don't love Rust with all my heart.

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

    very true. thank you :)

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

    Love you!

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

      Just encountered something in our code base today. Our FileStatus contains two bools, isOpen and isClose. So this creates 4 combinations, but some of them are not valid

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

      ❤️❤️❤️

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

    brilliant

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

    In python there IS SPECIFCLY with for the reasource issue and its quite nice.
    No need to pretend thst this is something we run into because it's not actually a thing in python

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

      Did you make it to 24:26? My goal with the open_outputs function was to talk about a case where `with` doesn't work for us. Another issue there that I didn't go into in this recording, is that lists aren't context managers in Python, so there's not an easy way to use the list of ScreamingOutputs with a `with` statement in the caller.

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

      @oconnor663 YES which is why I am complaining. You can't show bad python code and complain about the languge.
      In python the idiomatic way to do IO is
      With database.connect() as dc:
      Which automatically gcs the thing when you raise or similar.
      This is why you will see ALL the material online about python and file IO use a with statment

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

      ​@@nevokrien95 Forgive me if I'm repeating something you already understand, but my main point here is that `with` doesn't work in functions like this. If you have a function that's constructing a database connection and *returning* it, and you use `with` in that function, you'll return a *closed* connection and your caller will crash. If it's possible for exceptions to come up in that function after the connection has been opened, and you want to do cleanup correctly in that case, you have no choice but to use try/except (or maybe something more complicated like passing down a contextlib.ExitStack).

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

      @oconnor663 you open the with externally then send it in... for 99% of cases this works fine.
      Because most the time you either have 1 static connection in main OR you open a connection per action.
      In the rare cases you don't it's likely not something you anyway want to do in python for other reasons.

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

    came after seeing your "Shameless self-promotion :) th-cam.com/video/OQTwvycftJU/w-d-xo.html"

    • @codemob
      @codemob 2 หลายเดือนก่อน +1

      same!

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

    Python and Rust are completely different animals for completely different purposes, and they'll never compete with one another. Python is great for interactivity, learning, and easy-to-make scripts, when clarity and accessibility are important. It also has a lot of libraries. Rust is good for memory-safe and quick programs, but it's too complex and distracting for a learner and not interactive. Python is GC, Rust isn't. Python is mature and Rust isn't. Python is OO and Rust isn't (really). Don't compare apples and oranges.

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

      The underrated F# is a better fit with Python than Rust and is more mature and can play better with the Python ecosystem.

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

      Comparing programming language apples and oranges is a great way to figure out what one might prefer or need for a particular problem though.

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

    except no one can read it

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

    Good job not being red in this video ;)
    (Also, great video as always!)

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

      Taking it one step at a time over here :)

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

    except no one can read it

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

      You can. It's maybe a bit hard for a beginner but it's very readable at latest after a couple weeks.