I am a Rustacean

To me, "no" seems like the wrong kind of answer to "Is Rust object-oriented?". If you have to boil it down to 1 bit, it's much closer to "yes" than "no". The section of the book @vmedea linked discusses some different definitions of OOP and how Rust does or does not satisfy them. The only one that really doesn't fit is inheritance.

I wrote this in another thread, but it seems salient enough to copy and paste:

If there is an "oriented" term for Rust as a whole, I'd be inclined to call it data oriented, but that seems simplistic. Rust is a language that supports multiple paradigms. You can write object-oriented programs in Rust. It might not be quite as convenient as in Java, but it works fine. Maybe the problem is in trying to apply terms like "procedural" and "object-oriented" to a grab bag of language features rather than to the design of a specific program. Surely a procedural program doesn't become "object-oriented" because it's written in Java.

If you design a program or library around objects that have data and behavior and interact with each other, that sounds like OOP to me. And Rust supports that just fine, without using inheritance. Does that make Rust "object-oriented"? I sure don't know. Maybe it's not as object-oriented as a language like Java that supports the same things by using inheritance. Does that matter?

(I am reminded of this comic about the nature of art.)

1 Like