Settings

Theme

Objects, Identity, and Concept-formation (2008)

blog.higher-order.com

32 points by 1781 12 years ago · 41 comments

Reader

kazinator 12 years ago

"Object-oriented programming" in its basic form means that the data manipulated in a computer program is self-describing. We can ask a datum, "what are you? what type?". The functions of that program are organized around data. This is in contrast with the form of programming in which data is just some storage, which is given a meaning by the algorithm that operates on it; it is not self-describing.

Self-describing data lets us then have generic operations. For instance, if an object hold a sequence of other object, we can create an operation which extracts the N-th one. And we can make that same operation work for an object which is a character string, vector, list. This is because the function can inquire the object what it is, and then call the appropriate concrete implementation which does the right thing for that type.

This leads us to realize that type is connected to the operations which are applicable. Those objects are somehow of the same "kind". This gives rise to the concept of subtyping and substitutability: a string is a kind of sequence and so is a list and we can have operations on sequences.

The non-object-oriented concepts are all that cruft from various languages which tries to strangle OO: virtual base classes, protected members, methods within class scope, scope resolution, copy constructors, yadda yadda ad nauseum ... We are led to believe that OO requires this or requires that. It's not OO if there is no encapsulation. It's not OO if there is no language-enforced "information hiding". It's not OO if there is no private/public access mechanism. It's not OO if method calls aren't represented as message passing. It's not OO if methods aren't in a compile-time class scope together with data members. ...

  • tailrecursion 12 years ago

    Kazinator's comment struck me as a lucid definition. APIs and ADTs let the thing's behavior define the thing, and subtyping and substitutability emerge from thinking about generic operators defined on more than one kind of datum.

    My bet is even Smalltalk programmers don't think of eggs as knowing how to scramble themselves; but eggs do have an API, a behavior, that makes them distinct from other kinds of objects and at the same time shares characteristics with other objects, such as weight and dimensions.

    I can assemble a list of eggs, elephants, and cars, and write "take the sum of the weights of all the objects". Although these objects are of different kind, they share a common characteristic that would be exploited naturally by any language user. Exploiting multiple "views of a thing" is a feature of English ("natural language") and to my mind is a feature of any successful "generic programming" computer language.

    Processes communicating by asynchronous message passing is a better simulation of the familiar world; but that vision is not realized by Smalltalk, wherein messages are passed synchronously. What we want from language is the ability to write powerful sentences and have them mean something to the machine -- as long as the computer and human agree on the meaning. The better part of this power comes from a sophisticated treatment of type and generic operators.

  • l_dopa 12 years ago

    You just described parametric polymorphism, which has nothing to do with objects or runtime type information.

    • kazinator 12 years ago

      "has nothing to do" ... says you! I didn't describe static parametric polymorphism. Some of the things I described are doable with static parametric polymorphism in some limited circumstances.

      • l_dopa 12 years ago

        Well, you described parametric polymorphism (a generic Nth function) and then switched to talking about dispatching on tags at runtime. You are mistaken; those really are completely unrelated concepts.

      • asuffield 12 years ago

        Please, identify which things can't be done with parametric polymorphism. It is not clear what you are referring to.

TelmoMenezes 12 years ago

The term "object-oriented" was coined by Alan Kay, and he did provide a much more precise meaning. Unfortunately, the term became a fad and was then diluted into all sorts of vaguely related ideas.

http://c2.com/cgi/wiki?AlanKaysDefinitionOfObjectOriented

I find the original idea deep and worth thinking about.

  • techadv 12 years ago

    The page you link seems to indicate that Kay didn't propose this as a definitive definition of OOP, but rather as a description of the defining features of Smalltalk. I'm not familiar with the document; do you have any insight?

    • TelmoMenezes 12 years ago

      You are right. I've heard Kay provide short definitions. One documented case:

      "OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things."

      http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay...

      If you read this email, you will see that what he had in mind was much more than a way of programming. It was a model of computation where the computer is a networks of "cells" exchanging messages.

  • pfraze 12 years ago

    He gives some really good points about this in a talk delivered to OOPSLA in 97 [1].

    1. http://www.youtube.com/watch?v=oKg1hTOQXoY

  • kazinator 12 years ago

    Kay's concept survives if you substitute "function call" for "message". Sending a message to an object and receiving a reply is closely analogous to invoking a function and obtaining a return value. Unfortunately, his overall model implies single dispatch. Sure, "everything is an object", but only one thing is the leftmost argument: the thing that receives the message; and the other things are just arguments.

    • seanmcdirmid 12 years ago

      Wow, just no. Sending a message to an object is more like calling your mom. Applying a function is like...applying a function. There is no real analogue for that, it's just math.

      • kazinator 12 years ago

        It seems you need more time to think about it.

        Message passing can be synchronous, and function calls asynchronous

        Also consider remote procedure calls.

calvins 12 years ago

"Valid concepts are arrived at by induction."

If the point is to argue that OOP is not a valid concept, the author should show first that 'programming' is a valid concept (using the same definitions) and that there are some related concepts (e.g., 'functional programming') that are valid, because if the same argument can be applied to most or all other '* programming' concepts too (not to mention concepts like 'validity' and 'concept'), then the point is not specific to OOP at all.

Incidentally, http://en.wikipedia.org/wiki/Prototype_theory seems a much better starting point for thinking about concepts in general, and '* programming' in particular.

  • techadv 12 years ago

    The author's case is based upon Harriman's account of induction in the natural sciences. I don't think that's appropriate here. Computer Science -- or at least PL/Software Engineering -- is not a physical science! In many cases it's not or historically wasn't even a mathematical science.

    Furthermore, all programming paradigms suffer the same fate in popular/industry press (even if not within academic communities). For instance, productivity claims justified by the macros and dynamic typing of Schemes and Lisps are often implicitly cross-applied to MLs under the broad header of "FP". And vice-versa for safety claims about MLs germane to types.

    Sure, some people are careful about this sort of thing. But some aren't, which can make the concept of FP a "grab-bag" in certain settings. That doesn't (or shouldn't) make FP a "non-concept".

    (It appears you beat me to this punch, so I'm moving my comment here instead of fragmenting this point into 2 top-level comments.)

    • mbrock 12 years ago

      I was happy to see a blog about the intersection of functional programming and philosophy, but I'd be happier if it weren't Objectivist. On the other hand, it's nice to see that my Rand radar is working. At the first mention of "actual concepts," I was a little intrigued. Then I noticed arrogant statements like "abstraction that is made in error," and the typical retreat to Aristetolian epistemology in order to make some basically political point. Then I went back and noticed that the link to "epistemology" actually links to "Objectivist epistemology" and that the citation for the criteria of concepthood is from The Objective Standard ("Reason, Egoism, and Capitalism").

InfiniteRand 12 years ago

Well, the author recommends induction as a means of figuring this out, and it seems for induction to work we need to have some existing example to induce the principle from (if I am remembering my maths, I might not be). So to figure out our concept it may be worth taking a look at what the use of object-oriented features is, and use that as a starting point. Maybe, again I am a little rusty on my inductive reasoning.

I think one thing that strikes me with Object-oriented programming in general is the idea of data management and function management.

I guess if we look at the features that are associated with object-orientation (I am not pretending that I am being strictly inductive at this point, although I think this is vaguely inductive), I would say that it takes the management and organization of programming concepts, such as data and function organization, and embeds it into the language itself.

techadv 12 years ago

The mainstream programming language community has a pretty strong consensus on what OOP means, in terms of language features.

Some people out there seem to have some confused notions of what OOP is. That doesn't mean there isn't a well-understood and more-or-less accepted definition, at least in academia.

Edit for downvotes: dynamic dispatch + associating methods with classes, often times but not necessarily accompanied by an inheritance hierarchy. Of course there's lot of room for design decisions (and prototype-based languages are only awkwardly encapsulated in that group), but these features are basically unique to OOP languages.

The point is that you could put a language with these features in front of any random sample of PL researchers and they would probably more-or-less agree on whether the language has OO features. That's more or less the definition of scientific consensus.

  • yummyfajitas 12 years ago

    Edit for downvotes: dynamic dispatch + associating methods with classes...

    So Julia and Clojure are object oriented? Some "object-oriented" julia code:

        f(x: Int64) = ...
        f(x: String) = ...
    
    Even Haskell might qualify, due to existential types.

    http://www.haskell.org/haskellwiki/Existential_type

    • techadv 12 years ago

      I have no idea how defining the type of a function's domain is supposed to be indicative to dynamic dispatch or associated methods with classes. I think I don't understand your example :-( Perhaps you can elaborate, since I don't know much about either of these languages.

      Regarding existential types: yes, there's an intimate relationship between existential quantification and OOP. But you can distinguish the difference between OO languages and (non-OO languages with existential types) in the type theory. That's what's important. I think the raw empirical nature of my academic community consensus test is far preferable to the author's epistemological argument.

      The question is whether OOP has meaning. I think if the PL community can be empirically demonstrated to have enough consensus that languages are reliably categorized as OO or non-OO, then we can safely say the term has meaning regardless of any armchair philosophy to the contrary.

      Edit: And I think (hope) the author of the article would agree my test is sufficient. He states: When I say that there’s no such thing as OO, I mean, more precisely, that there exists some abstraction (or several) that is referred to as “object-oriented”, but that this abstraction has no actual referent in reality. It is an abstraction that is made in error. It is not necessary, and serves no cognitive purpose. It is “not even false”..

      If OO has enough meaning to an important subgroup of people that they can use it with more-or-less consensus, then the claim that it has no referent in reality is clearly empirically denied, at least for that subgroup. And if that subgroup happens to be a large chunk of the PL community, then I think that's an important enough subgroup to settle the larger question.

      • yummyfajitas 12 years ago

        Julia/Clojure/Lisp does dynamic dispatch on the argument types of the function - it's called multimethods. So it seems to fit your criteria of "dynamic dispatch + associating methods to classes".

        And in some sense, it is used for object orientation - CLOS is built on it. But on the other hand, these languages are very far from what one would normally normally call "object oriented".

        I do agree with you that there is some meaning to the term "object oriented" - I often completely understand what is intended by the term. Python is certainly OO, Haskell is almost certainly not. But to some extent I agree with the author - it would be very useful to have a precise definition, because I don't think that classifying stranger languages as OO is that reliable.

        • techadv 12 years ago

          Great, thanks! Your example makes a lot more sense now.

          The easy way out is to say that these languages are OO in the same sense that Java is functional. Easy but maybe not unfair, particularly since all are dynamically typed.

          The clojure examples make this look like OO. I would have to find a formal definition of the semantics to figure out if there's a more nuanced explanation than the easy one above.

          And yes, I think I agree with the last bit. The author's observation that lines can become blurred is certainly valuable and true. It's the author's conclusion that the term OOP is therefore meaningless which is, imo, empirically false.

          edit: stray punctuation

        • kazinator 12 years ago

          CLOS is completely, thoroughly, dyed-in-the-wool object oriented. It gives you generic functions which dispatch methods, by considering the class type of every (specializable) parameter. CLOS also avoids the silly problems by not putting methods into a class scope and dealing with symbol-table conflicts upon inheritance: like when inheriting from "graphical" and "lottery", working out whether the "draw" method renders pixels, or performs a lottery pick.

          The CLOS design absolutely nails OO, and that's even before we look at the meta-object protocol.

    • Dylan16807 12 years ago

      Those are function overloads? Does it pick the overload based on the runtime type of a variable that can hold multiple types? Can you create arbitrary multi-member types to apply this logic to?

      Then code using that dispatching to implement behavior would be object-oriented, I think.

      If not then no.

      Also it's code that's object oriented or not, a language 'being' object oriented is a discussion of how well it supports such a thing. But they're all turing compatible; with enough abstraction you can write any type of code on top of any language.

kazinator 12 years ago

There is such a thing as object-oriented programming; the author just hasn't encountered it through the tools that he was led to believe were OO programming tools.

"I didn't find Tao in Java or GoF" does not imply "there is no Tao".

audionerd 12 years ago

Alan Kay coined the term "object-oriented" for software architecture in the late '60’s. He offers a good explanation of it: http://programmers.stackexchange.com/a/58732

“OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.” — Alan Kay

It's easy to assume only languages with Class and Object abstractions are "object-oriented", but the "orientation" is really more about your mental model of the system as differentiated objects that communicate via messages.

mpweiher 12 years ago

http://www.dreamsongs.com/ObjectsHaveNotFailedNarr.html

dang 12 years ago

Url changed from http://runarorama.github.com/blog/2008/12/04/no-such-thing/, which redirects to this.

a3voices 12 years ago

Programming in C which isn't "object oriented" is very similar to say, Java. You make the same architectural diagrams on a whiteboard for both. So I agree with the author.

  • gress 12 years ago

    Java is a deeply flawed object oriented language. You agree with the author because, correctly, you are experiencing that Java barely supports object oriented programming. Not that there is no such thing.

    [edit: Why the downvotes? I'm not saying java is bad - just that it isn't a strong representation of object orientation. If you take Java as the examplar of object orientation, then you will reasonably conclude that Object Orientation is a weak concept.]

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection