Search code examples
programming-languagesparadigms

Confused. Is OO inherently imperative or is is it multi-paradigm?


As I have read through stackoverflow answers and questions I am getting the impression that OO is compartmentalized to to be inherently imperative.

But isn't OO just a way to compartmentalize code and data into real world Objects?

If so, why would that forgo other lower level paradigm to work in such a platform?

IOW, an Object Based generic type system that is immutable by default would be the way a functional first language would work, an object based generic type system that is mutable by default would be the world of imperative languages.

Or am I missing something altogether?


Solution

  • No. OO and imperative are two orthogonal concepts.

    For example:

    • The Common Lisp Object System is an example of Lisp OO and maybe the most complex object system around.
    • OCaml is a functional language with an object system and a module system supporting object-oriented organization
    • Scala is a functional language with a very flexible OO system
    • Haskell allows you to write object-oriented code using higher-kinded polymorphism

    There are lots of different ways to be object-oriented.