top | item 14997256

(no title)

wfunction | 8 years ago

No, it absolutely is not. OOP has lots of well-known unique characteristics such as inheritance, dynamic dispatch, polymorphism, encapsulation, etc... as well other less-frequently-noticed semantic differences like the fact that the message-passing follows a subroutine model (which may be more difficult to appreciate if that's the only thing you're used to). Yes, you can do OOP in C, but just making a struct and defining procedures to operate on it doesn't imply any OOP.

discuss

order

jcelerier|8 years ago

> OOP has lots of well-known unique characteristics such as inheritance, dynamic dispatch, polymorphism, encapsulation, etc...

OO just means that you have a semantic entity, the object, which contains data and to which you associate code. Your main tool to work with is this object; just like in FP your main tool to work with is the function to which you associate data through closures and currying. Likewise, in logic programming your main tool is the constraint. And these aren't relevant to the language. You can do both OO and FP in most mainstream languages.

> dynamic dispatch

is just allowing to associate a different implementation to the same function name. Every languages that have some kind of function pointer allow this.

> polymorphism

is in almost every language, including FP.

    data Tree a = Empty | Node a (Tree a) (Tree a)
is polymorphism. C++ templates are polymorphism. Rust traits are polymorphism.

> message-passing

is only relevant if you adhere to Alan Kay's vision of objects. I personally don't (even if the guy coined the term).

wfunction|8 years ago

A lot of misunderstanding in what you wrote, but to comment on two parts:

> Every languages that have some kind of function pointer allow this.

It doesn't seem like you're reading the discussion. The claim the parent made was that "every time you do {X}, it is OOP". My reply was "yes, you can do OOP in C, but OOP implies far more than just {X} (it implies {Y}, etc.); merely {X} does not imply OOP".

You reply with "languages that have function pointers allow {Y}". Well yes, they do allow {Y}. Most/all of them in fact probably allow OOP in full. Nobody suggested such languages don't allow OOP (in fact I said the opposite about C). What does that have to do with the entire discussion and argument? Your argument isn't even wrong... it doesn't even compile.

> message-passing is only relevant if you adhere to Alan Kay's vision of objects. I personally don't (even if the guy coined the term).

This 100% completely misses the point of what I said. Replace it with "procedural call" if you're allergic to "message passing". The point I was making was we're talking about subroutine calls: you call a procedure and wait for it to produce a single value as the resulting output before proceeding. Again: if you're not used to other paradigms then that might be why you're missing my point here and adversely reacting to superficial things like the nomenclature. Whether you dress it as message passing or anything else has nothing to do with the issue.

tzs|8 years ago

This thread brings to mind an old quote:

  What is object oriented programming? My guess is
  that object oriented programming will be in
  the 1980s what structured programming was in
  the 1970s. Everyone will be in favor of it.
  Every manufacturer will promote his products
  as supporting it. Every manager will pay lip
  service to it. Every programmer will practice
  it (differently). And no one will know just
  what it is.
Tim Rentsch, "Object Oriented Programming", SIGPLAN Notes, v17, n9 (1982).

tome|8 years ago

I fear this is the destiny for functional programming in the 2020s.

seanmcdirmid|8 years ago

OOP is all about the nouns while FP/procedural is all about the verbs. That's it really: are you modeling your system in terms of objects (nouns) or behavior (verbs)? It is super easy to tell just by looking at the names in your code. Semantic features only play supporting roles, they don't define the paradigm.

jcelerier|8 years ago

that's a nice definition