top | item 39889924

(no title)

hydroxideOH- | 1 year ago

I disagree. In Rust, traits are used all over for dynamic dispatch, the defining feature of object-oriented programming. Moreover, all three languages support structural pattern matching (borrowed from functional programming) as a core control-structure.

Certainly all three languages can be used in a simple, imperative style. But that's not the only paradigm that can be used unlike in C or early versions of Python. Many programs in these languages look significantly different than just statements and procedures.

discuss

order

justinpombrio|1 year ago

> In Rust, traits are used all over for dynamic dispatch, the defining feature of object-oriented programming.

In my experience, Rust traits are used much more for static dispatch `fn foo<T: Trait>(T)` than dynamic dispatch `fn foo(Box<dyn Trait>)`. This, together with its ADTs and lack of inheritance, gives it a very different feel from most "object oriented" languages.

Also, what counts as a "defining feature" depends greatly on who's defining it. Though dynamic dispatch is certainly up there on most lists.

bradrn|1 year ago

> Many programs in these languages look significantly different than just statements and procedures.

Like I said, they’ve certainly adopted features from other paradigms… but the basic, underlying structure of programs in these languages is still statements, sequenced one after another. It’s not like Haskell or Scheme where nearly every operation is ultimately done through function calls. And it’s certainly not ‘post-paradigm’ as the article claims.

> Moreover, all three languages support structural pattern matching (borrowed from functional programming) as a core control-structure.

As for this: people often associate functional programming with pattern-matching, but I’ve never really understood why. The only relationship is that it originated in the ML language family, which also happens to be functional. There’s many functional languages which lack pattern-matching (e.g. most Lisps), and there’s many non-functional languages which have it (Java, C#, Python).

lispm|1 year ago

I would think pattern matching as coming from string processing (https://en.wikipedia.org/wiki/COMIT , SNOBOL, ...) and pattern-directed programming coming from rule-based & logic programming (PLANNER, Prolog, ...).

agumonkey|1 year ago

Bro, Java and python just got it. Lisps don't include it because it's just another lib/extension. Even emacs had one (see the recent pcase lawn article)

blarg1|1 year ago

Dynamic dispatch doesn't solely belong to the OOP paradigm.