• Júlio Gardona
    link
    fedilink
    4
    edit-2
    9 months ago

    @onlinepersona @snaggen

    people write oo code in linux source code using c. With rust is simple. Just use composition, and you can explore the traits, that serves as and is better than interfaces.

    • Júlio Gardona
      link
      fedilink
      1
      edit-2
      9 months ago

      @onlinepersona @snaggen another problem I see people doing while writing rust, is trying to write code like java. Rust isn’t an OO language, but you can organize your code and have hierarchies.

      • @nous
        link
        English
        89 months ago

        Rust isn’t an OO language, but you can organize your code and have hierarchies.

        IMO I think this is a common fallacy. OOP does not mean inheritance/hierarchies (despite them being part of every introductory OOP course nowadays). The original meaning of OOP had nothing to do with inheritance, that idea was mostly popularised by Java. And these days not even Java devs recommend inheritance as the first port of call but instead often favour composition and interfaces as the better language constructs.

        Rust is as good at OOP styles as it is functional or procedural, if you ignore inheritance as a requirement of OOP. And a lot of code in rust can look and feel like OOP code in other languages. The abilities to encapsulate state, and polymorphism your code are far better features of OOP and both are well supported in rust. IMO rust offers the useful features from all paradigms fairly equally, which lets you write in any style you like, or even mix and match depending on the various situations. As one is not always better then the others, but each alone is useful in specific situations. More languages should be like this rather than forcing everything into one mold as it lets you pick the best style for each task.