4 ms·
Don't let the Rust fanboys catch you calling it OO.
by look_lookatme 9y ago
Don't let the Rust fanboys catch you calling it OO.
- saghm 9y agoWhy? OO doesn't have to have inheritance.
- steveklabnik 9y agoThe second edition of the book has a chapter https://doc.rust-lang.org/nightly/book/second-edition/ch17-00-oop.html https://doc.rust-lang.org/nightly/book/second-edition/ch17-0... I personally don't feel Rust fits into either of the two big schools of OOP, but that doesn't mean that it's not OO. Part of the problem with OO is that the definitions are hard.
- saghm 9y agoI tend to think of OO as a spectrum rather than a binary thing, and I think that Rust certainly belongs somewhere on it. I'm not convinced there's any language that can be considered "completely object-oriented"; Java has primitives, and Python, while considering everything an object, is perfectly content to let you use functions and variables without writing a single class. JavaScript doesn't even have classes, but I think it still can be considered to be at least partially OO. I might just have a more liberal than average interpretation of what OO means, though.
- jholman 9y agoI think that's actually an unreasonably strict interpretation of OO, actually. First, lack of classes is no reason to eliminate JS, it's not Class-Oriented programming. (not that I think JS is particularly OO; certainly not "completely OO") Second, it's not Object-Only programming, so I'm not sure why you'd rule out any language with primitives. Much as I detest Java-style OO, I think it's very clear that its orientation is towards objects. And third, even if you want to stick to those two rules, what about Ruby? Every value is an object, it has classes, and you can't write functions (only methods).
- saghm 9y agoI didn't mean to give the impression that I didn't consider JS to be object-oriented, although I realize now I wasn't quite as clear as I originally intended. When I said "at least partially OO", I meant that I wouldn't agree with an assertion that said JS isn't OO at all, not that it's only partially OO. After all, Rust doesn't have classes, and my original point was that I think Rust is somewhat OO. Similarly, I wasn't saying that Java isn't OO either; I was attempting to make the point that I could see plausible arguments saying that either Python or Java is "more OO" than the other. Personally, I consider Java to be more OO than Python, but I'm not sure I could make a compelling counterargument to the idea that Python is more OO due to everything being an object. As for Ruby, I'm not sure I understand what you're saying; Ruby lets you just write top-level functions and variables just like you can in Python. I also think you might have misinterpreted my giving examples as being "rules"; I certainly can't come up with any objective rules to determine whether a language is OO or not. I must not have made myself very clear, but the main idea behind what I was trying to convey is that I don't think anything is "completely" object-oriented and that plenty of languages fall somewhere on the spectrum of OO languages.
- matt_kantor 9y ago> As for Ruby, I'm not sure I understand what you're saying; Ruby lets you just write top-level functions and variables just like you can in Python. I don't know much about Python, but in Ruby top-level bindings are just syntax sugar for attaching things to an object called "main". [0] [0]: https://codequizzes.wordpress.com/2014/04/23/rubys-main-object-top-level-context/ https://codequizzes.wordpress.com/2014/04/23/rubys-main-obje...
- wtetzner 9y ago> I'm not convinced there's any language that can be considered "completely object-oriented"; Maybe Smalltalk? > I might just have a more liberal than average interpretation of what OO means, though. I think the problem is that there's no clear definition of OO, and at some point the term becomes meaningless.
- look_lookatme 9y agoI agree, but that doesn't matter to a certain segment of the Rust community. They will go to great lengths, including redefining what OO is, to disassociate their language from OO for whatever reason.
- saghm 9y agoI haven't personally seen this before, but I can't say for sure I know it doesn't happen
- andrewflnr 9y agoSometimes on say, /r/rust, they get questions from people wondering how to "do OOP" with Rust, by which they tend to mean "traditional", inheritance-style OOP. This leads to Rustaceans having to explain "no, that's not exactly how it works here". I'm not sure that's what GP is talking about, and I can't think of a time when I saw someone really aggressively dissociate from OOP, but it's easy for me to believe that some people might take it too far.