It’s getting more and more unhinged on LinkedIn.

  • sugar_in_your_tea@sh.itjust.works
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    6 days ago

    the lack of OOP

    Rust absolutely has OOP, that’s what Traits are for. It just doesn’t have classical inheritance, so you structure your patterns a bit differently.

    That said, I lean more into functional-inspired style anyway, which tends to work pretty well w/ Rust.

      • sugar_in_your_tea@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        3 days ago

        At its core, OOP is just commingling data and operations, whereas FP is separating data from operations on data. I’m not an expert at Haskell (I cut my FP teeth on Lisp), but that’s essentially what typeclasses look like to me.

        The Rust book has a section on OOP, and the main thing to remember is that Rust solves OOP through composition instead of inheritance. Rust doesn’t have inheritance in any meaningful way, but it can solve problems in a similar way as classical OOP.

        • beleza pura@lemmy.eco.br
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          3 days ago

          i would strongly disagree with that characterization of both fp and oo. classifying rust as oo weakens it imo, and the fact that you can easily solve all the problems oo solves in rust, as your linked document shows, is not proof rust is oo, but rather that oo is unnecessary to solve those problems

          object orientation is classes done wrong. typeclasses (and traits) are classes done right

          • sugar_in_your_tea@sh.itjust.works
            link
            fedilink
            arrow-up
            1
            ·
            3 days ago

            Then how would you define OOP and FP?

            Wikipedia claims it supports OOP:

            Rust does not enforce a programming paradigm, but was influenced by ideas from functional programming, including immutability, higher-order functions, algebraic data types, and pattern matching. It also supports object-oriented programming via structs, enums, traits, and methods.

            I wouldn’t say Rust is an OOP language though, because that absolutely gives the wrong impression since that evokes ideas of classical inheritance as in C++ or Java. But I do very much believe it supports object oriented programming as a paradigm, since you can model things with objects at the core.

            That said, I think Rust is best used with less emphasis on OOP, since it’s pretty easy to get into trouble modeling things that way when it comes to lifetimes. I use OOP-style in Rust when it makes sense, and the rest is as close to functional as I can get it.

            object orientation is classes done wrong

            I think classical inheritance is object oriented programming done wrong. Go had the start of a good idea with composition and interfaces, and I think Rust’s traits + generics improved on it.