Object Oriented Programming in Rust

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

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

  • @letsgetrusty
    @letsgetrusty  3 года назад +5

    📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet

  • @chrs-wltrs
    @chrs-wltrs 2 года назад +29

    "It's *so* different, I had to pause recording and get a haircut before I could talk about it."

  • @----__---
    @----__--- 3 года назад +49

    content idea: going over the changes in the just released rust 2021 edition. i think would be a nice video.

  • @emoutraspalavras-marloncou4459
    @emoutraspalavras-marloncou4459 2 года назад +21

    I loved the joke about the video pausing and haircut.... Bogdan, you are a great teacher!

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

    To those confused this is almost the same as getter & setter in classes.
    Or in simplier terms a wrapper script to view & edit the fields in a struct. Because you won't allow the program to directly view or manipulate its value.

  • @kasabuckialexandr335
    @kasabuckialexandr335 3 года назад +19

    Nice job! Thanks!
    Previously you mention that you worked with TS and JS. It will be interesting to hear what are you using rust for

    • @letsgetrusty
      @letsgetrusty  3 года назад +16

      I'm not using Rust for anything particular at the moment but I plan on doing backend development in Rust. WebAssembly as well.

    • @kasabuckialexandr335
      @kasabuckialexandr335 3 года назад +3

      Same for me. I Wanna try it on the battlefield

  • @DissyFanart
    @DissyFanart 2 года назад +6

    For anyone interested in the average vector thing. You should really set a flag to update the average next time the get avg method is called to reduce the overhead for entering or removing data from the vec

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

      Also you could use a moving average, so you don't have to iterate through the array every single time a value is added

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

    Man, I love the way you're explaining things, very good!

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

      You do realize he's mostly just reading the words on the book?

  • @smileynetsmileynet7922
    @smileynetsmileynet7922 2 года назад +2

    Inheritance is important! Without it, the language im developing wouldnt work! If i can first debug my read instruction, and then make a "brain", and fix objects, i can rewrite itself in itself. That would be great!

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

    Gave this video a huge hug :]

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

    the haircut joke was good though

  • @69k_gold
    @69k_gold Год назад +1

    It's not an OOP language by any means. It's just better C. C also has structs and library files can be used to hide function implementation. But this isn't OOP

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

      You don't understand the essence of OOP then. Technically C can be used for OOP. It's just that some languages make this easier. And some don't even run without forcing OOP in your mouth.

  • @T--T
    @T--T 2 года назад

    thanks, it was helpful to see the code example

  • @googleuser2016
    @googleuser2016 3 года назад +4

    Great video! One request, when you go into dynamic dispatch: I have a problem on how to deal with mock objects in tests. For example on the raspberry I try to test against mocked SPI and pins traits. But somehow injecting a dependency and accessing the mock functions (like expect, return, times etc.) is impossible, I don't get how dynamic upcasting works. Or do I need a generic struct? Help! =)

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

      No helpful replies to followers? =(

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

      You implement functionality through a trait, the mock object provides its own implementation, then you use a trait object to use call the trait api

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

    Hey Rusty, are you currently working as a Rust developer? What type of programming were you doing before systems programming? Thanks bro

  • @jonathanmoore5619
    @jonathanmoore5619 3 года назад +3

    I always preferred Composition anyway...

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

    Good luck sir🤞.
    how to choose between : rust golang kotlin for entreprise systems (business intelligence erp crm mrp gui marketing web... )

  • @RufusROFLpunch
    @RufusROFLpunch 3 года назад +3

    That’s a bachelor pad if I’ve ever seen one.

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

    lol. the haircut part 🤣

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

    Hmm .. Iv'e been OOP-ing for a lifetime now. It seems that it kinda has all that is needed. Usually inheritance for me is 1 or 2 levels deep. I still prefer recomposition so... why make it more complicated? What I am very found of are interfaces. ... But there are traits. With a bit of discipline it is workable but it can turn into a clusterfuck especially with an unreadable language like rust.

  • @kid_kulafu_1727
    @kid_kulafu_1727 3 года назад +3

    Yow bro can also include in part2 of OOP chap17 the rust implementation of state pattern. It's really confusing. Thanks much bro. much

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

      Yup that video is coming up next!

  • @MattTheCuber1
    @MattTheCuber1 2 года назад +2

    The haircut 😂

  • @АртемФедоров-ю7б
    @АртемФедоров-ю7б 9 месяцев назад

    So it's 2 years later, is this proposal accepted? It's common case when you encapsulate the behavior based on some state, because of traits can not define data properties to be implemented for Struct/Enum the only way is to use getter/setter methods instead, and then care which of them should public or private

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

    you can create modules which inherit from a parent module, right?

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

    is IMPL the same as CLASS in other languages?

  • @emvdl
    @emvdl 3 года назад +2

    A registered for the cheatsheet, buy didn’t receive one :-)))

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

      Still in the works. You'll receive an email once it's done!

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

    where is sync and send trait video ??

  • @Stefan-zt1qk
    @Stefan-zt1qk Год назад

    Your missing the self.update_average(); in the add function :) Good Video's!

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

    Damn, dude, that haircut joke, lmao)

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

    Why was this topic so late in the video's?

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

    Sir please make your rust community on discord/matrix. please we really really need it. Thank you :)

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

    Naah, very poor algorithm: just take a few very large i32 numbers and add them... Your _total_ in update_average() is itself an i32, so what will happen very quickly?
    Better idea: instead of the average, store the _sum_ as an i64 in the first place. Every time you add an i32, just add. Every time you remove, substract. Calculate the average only when requested. OK, store it as well so that it is only recalculated when a change has happened, otherwise return the stored value.

  • @coffee-is-power
    @coffee-is-power 2 года назад

    Too much of anything is bad and using OOP has limits, so rust makes OOP optional which is much better than other languages

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

    Are you me?
    1. Bogdan ✔
    2. Ukraininan ✔
    3. TS/JS Develepoer ✔
    4. Want to use Rust for backend ✔
    ...
    🤔

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

    6:01lol

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

    gg