3 ms·
I'd consider something OOP if it has the same expressive power i.e. things expressible in OOP languages are easily expressible in another OOP language as well.
by Ygg2 4y ago
I'd consider something OOP if it has the same expressive power i.e. things expressible in OOP languages are easily expressible in another OOP language as well. And for Rust that's not the case.
Otherwise you end up with Haskell is an OOP language.
- ModernMech 4y agoTo me, OOP always meant passing messages to objects, but it seems everyone has their own definition depending on experience.
- pjmlp 4y agoI will debate it is one, yes. Just like being an FP language isn't "like Haskell does it", when I learned FP, Haskell didn't even exist. Try to express Eiffel, CLOS, SELF or BETA in Java. By the way, here is One Weekend Raytracing in Rust, perfectly using OOP with dynamic dispatch and interfaces (sorry traits). https://github.com/pjmlp/RaytracingWeekend-Rust https://github.com/pjmlp/RaytracingWeekend-Rust
- Ygg2 4y agoOk. But noticed what I said. *Things* that are easy in one OOP should be similarily easy to express in other OOP language. Counter example: Html5 DOM.
- pjmlp 4y agoCounter example of what? A graph representation of nodes based on JavaScript object model? Fine, https://rustwasm.github.io/docs/wasm-bindgen/examples/dom.html https://rustwasm.github.io/docs/wasm-bindgen/examples/dom.ht...
- Ygg2 4y agoYeah but if you dig deeper you'll notice it is riddled with unsafe, casts and Deref misuse. It's a brittle simulation of Inheritance. To transform a saying "Just because you can write Ada in C, doesn't make C Ada".
- Ygg2 4y agoPost Scriptum: one way to prove this is that we could use https://www.youtube.com/watch?v=43XaZEn2aLc https://www.youtube.com/watch?v=43XaZEn2aLc as a base. How to prove. Assume that we add struct inheritance to Rust (it looks similar to JS) - call it RustInh. Does adding inheritance to Rust increase expressive power? If yes, then right now Rust can't express OOP concept as inheritance. I.e. is there a C[RustInh] = C[Rust]. And way to prove it is to look at Deref anti-patterns https://github.com/rust-unofficial/patterns/blob/main/anti_patterns/deref.md https://github.com/rust-unofficial/patterns/blob/main/anti_p... I'm still not sure that fully captures my intuition of easy to write.
- masklinn 4y ago> I'd consider something OOP if it has the same expressive power i.e. things expressible in OOP languages are easily expressible in another OOP language as well. That doesn't even make sense on its face. There are things which are trivially expressible in Smalltalk and I'm not sure even possible to wrangle in Java.
- Ygg2 4y agoThat's because Smalltalk OOP isn't the OOP in the sense Java is, some refer to Java Style as Class oriented Programming.
- masklinn 4y agoThat doesn’t make your original comment any less nonsensical, and still makes no sense: Smalltalk is very much class-based. Are you mixing up Smalltalk and Self?