Is Rust OOP? If not, what is it oriented to?

Since most programming languages have wildly diverged from the original definition of their (main) paradigm (ironically, OO is probably one of the best examples of the phenomenon), and since almost everyone defines these words differently anyway, I find it largely pointless to ask questions of the form "Is X a Y-oriented language?", and even more so to answer them with a simplistic "yes/no". To that end:

Rust is…

  • …a language whose main goal and promise is to bring compile-time-proven memory safety and thread safety together with runtime performance, ideally without compromising either;
  • …which is achieved via a unique combination of half-century-old and novel good ideas from the history of programming language design; drawing heavily on
  • …interface-/protocol-/typeclass-/trait-/whatever-you-call-it- based programming complementing real, parametric polymorphism aka "generics" aka "type-level functions";
  • …making the strong static typing easier to digest for the programmer via extensive and smart type inference;
  • …mixing in the basics of algebraic type systems found in traditional statically-typed so-called functional languages, such as Haskell and its family;
  • …as well as the superb pattern matching abilities of said languages;
  • …allowing as syntactic sugar for function calls what many consider "THE object-oriented syntax";
  • …although the latter was never the essence of object-oriented programming – according to some, myself included, it is instead encapsulation, which Rust also provides via the simple concept of visibility modifiers;
  • …while it also cleverly manages mutable state, allowing for the so-called procedural-imperative paradigm to be embedded into the language without undermining its safety.

As you can see, that's quite a mouthful; in my opinion, every one of these is an important (although probably not equally important) building block of the language, and I rely on almost every single one of them in my daily Rust programming. Furthermore, I observed two changes in my own programming style after digging deeper in Rust:

  1. It is nothing exactly like the preferred idioms of any other language, but each of its features brings in and improves upon a certain style that is connected to the language where said feature was borrowed from.
  2. I increasingly miss the ability to follow these idioms when I work in other languages. :grin:

OK but I just need to fill in a stupid quiz for an Intro to Programming course, so please just tell me if Rust is OO or not!
In this case I'd lean towards "no". At least it's not the main, most prominent characteristic of the language. Instead of being religious about the One Right Way to do things architecture-wise, I think Rust is pretty malleable and fits many (sensible) styles well, as long as it leads to the highest possible degree of correctness. Oh, yeah, it's however pretty darn opinionated about how you should deal with your mutable pointers. I'll give you that maybe it should be called an "RWLock-oriented language", then. :stuck_out_tongue:

44 Likes