Live data from Hacker News

Alan Kay on the misunderstanding of OOP (1998)

lists.squeakfoundation.org

31–40 of 212 posts

Re: Alan Kay on the misunderstanding of OOP (1998)

#31
post #8

How is messaging different than calling a method?

Short Answer:

Calling a method is "Command and Control" where "command" is about getting a thing to do something that you want, and "control" is about preventing a thing from doing something that you don't want. In any case, you're running the process.

Message passing is about negotiating with something that is already in process. It turns out that this is the key to building scalable¹ systems (for all the usual reasons: enforcing loose coupling, abstraction, decentralization, etc.)

Longer Answer:

1. The actual powerful thing about a general-purpose computer is that it can simulate anything, including a "better" general-purpose computer (think about what Universal Turing Machine means).

2. Recursion is about making the part as powerful as the whole

Putting those two together leads to the original insight behind OOP: Why not build systems out of (scaled-down) computers!

So, in de-jure OOP, objects are supposed to be computers. Sometimes they are general-purpose computers (i.e. they contain an interpreter for a "Turing Complete" programming language), often times they are more limited special-purpose computers (e.g. functions, procedures, programs, etc.) . Crucially, the only way to interact with a computer/object is to send it input and receive output. It's completely up to the computer as to how to interpret the message (n.b. each object contains an interpreter). I like to think of OOP as being about scaling computer networks in both directions: scaling up gets you something like the Internet, scaling down can get you something like desktop publishing (I recall that Alan Kay said something like desktop publishing was really just about getting rid of the borders between apps).

While, in theory, method calling and message passing are equivalent, the problem with method calling is that it tends to limit you to building systems out of mere data structures that just happen to have all of the functions/procedures conveniently "nearby". Data structures are good if you want to make a process, but lame when you need to deal with one.

¹Scaling to me means that, with respect to some metric, there is a point at which the difference between the addition of part_n and the later addition of part_(n+1) becomes negligible. A part can be lots of different things: e.g. a user (metric is performance), an edit to the codebase (metric is pain), a new compute node in a network (metric is cost), etc...

(For the mathematically inclined, I think scaling is about making sure that the sequence of steps for building a system is Cauchy.)

Re: Alan Kay on the misunderstanding of OOP (1998)

#32
post #16

Earlier quoted context omitted.

Here's my understanding of the general idea (let me know if I got something wrong!). Say you have a bunch of computers with different software and hardware. You come up with a cool new image format called "PJEG". To get the images to show up on all the computers, you typically do the following: * Publish a PJEG spec * Define a .pjeg extension and let everyone know that means it's a PJEG file * Write a PJEG encoder/vi…

An interesting idea but wouldn't this require a universal interpreter and format to decode to? Seems a like certain things on the web already. Just the bounds on what the "file" is are a bit messy.

Not necessarily. That was one of the points Alan made in his AMA when suggesting 'send processes rather than messages'[1] That thread used the example of how to find things and then what to do when you find them.

[1] https://news.ycombinator.com/item?id=11948686

Re: Alan Kay on the misunderstanding of OOP (1998)

#33
post #17
post #12

Earlier quoted context omitted.

Alan commented on this several times in the AMA he did here a couple days ago: https://news.ycombinator.com/item?id=11957001 https://news.ycombinator.com/item?id=11945986 https://news.ycombinator.com/item?id=11945123

I have to admit I still have basically no idea what he's talking about when he says 'messaging'. A practical example would be useful for us non-CS-degree programmers who don't speak any of the CS lingo.

The idea is to replace "calling a function" with "sending a message".

Traditionally a function call is fixed at compile time (with some exceptions such as function pointers). In C a function is just an address; if we want to call foo(), we must have that function available at address &foo. C++ added flexibility by allowing there to be multiple functions called foo() with and a set of vtables[1] that store the actual (C-style) address. Other variations exist, but all of these traditional styles map function calls to specific code that runs every time the function is called.

Message change all of that. Instead of vtables (or similar)

    obj = create_foo()

    # instead of calling foo's bar() function directly, e.g.
    foo_bar(obj)
    # or perhaps
    obj.bar()
... we send a message by name of the function we want to call to the object itself

    obj = create_foo()
    obj.send_message("bar")

    # if function args are needed, include them as an array
    obj.send_message("baz", [42, "quux"])
The idea is that while the message can be effectively the same as a function call, it doesn't have to be. In a proper OO language, this message sending is handled automagically by the syntax.

    # instead of handling the messages directly, e.g.
    obj.send_message("bar")
    # the language does that for you when you call
    obj.bar()
    # in some languages, these are equivalent
In many cases the "foo" class above will handle the message "bar" by running the appropriate function, but that isn't required. For example, in ruby when no function exists for a given message, the raw message is send to the #method_missing function.

    class Foo
      def method_missing(name, *args, &block)
        puts "#{self.inspect} I was sent message #{name.inspect} with args #{args.inspect}"
      end  
    end  

    >> obj = Foo.new
    => #
    >> obj.bar()
    # I was sent message :bar with args []
    => nil
    >> obj.any_name_we_want()
    # I was sent message :any_name_we_want with args []
    => nil
    >> obj.any_name_we_want("args", "are", "optional")
    # I was sent message :any_name_we_want with args ["args", "are", "optional"]
Thinking of "obj.method()" as a message instead of only a function is much more flexible.

[1] https://en.wikipedia.org/wiki/Virtual_method_table

Re: Alan Kay on the misunderstanding of OOP (1998)

#34
post #8

How is messaging different than calling a method?

One example is the HTTP GET request. This was originally conceived of as a file download, where the URL path is mapped directly to filesystem paths. GET as an RPC: "download the file at this location." But in modern thinking, HTTP GET is a request with abstract semantics. The URL's path is abstract, and may be interpreted arbitrarily by the server. The client has no idea whether the request is serviced by a simple se…

As defined in both RFC 1945 and 2616 (that is, as always has been defined): "The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI."

The thing is that there's no difference between abstract and concrete semantics in terms of definition of what is a function or message and what is not. You can send a message or call a function with very concrete semantics ("please, check if that file exists") or with something very abstract ("please, execute a job").

The real difference of the message and function definitions is how they are executed. With message you pass the information on what do you expect to be done to the underlying infrastructure, which has to find the actual code to complete the delivery. With functions you are supposed to know, what exactly code you are calling.

In modern world the discussion about these differences in context of OOP classes does not make much sense: virtual methods of interfaces do their job as well for local invocations (JVM in Java world or VMT in C++ does the binding job), so it does not matter whether you call them messages (which may be right, considering dynamic nature of the call) or functions (again, it's correct, because as in C++ case there's no special mediator passing the call and in Java JVM is practically invisible to application programmer). The cases, when message delivery does not coincide with invocation of single method are rare and normally solved with application level architecture (design patterns like Facade are good example of the solution).

What's more important, IMHO, is that this talk about importance of messages is no more relevant to current problems of object-oriented programming. I do not think today we are really concerned about object interactions, rather we have to fight the enormous complexity of big projects, finding better ways of generalization (by means of more expressive languages and metamodels) and API contract clarification and enforcement (by elimination of side effects and correct handling of corner cases).

Re: Alan Kay on the misunderstanding of OOP (1998)

#35

Earlier quoted context omitted.

One example is the HTTP GET request. This was originally conceived of as a file download, where the URL path is mapped directly to filesystem paths. GET as an RPC: "download the file at this location." But in modern thinking, HTTP GET is a request with abstract semantics. The URL's path is abstract, and may be interpreted arbitrarily by the server. The client has no idea whether the request is serviced by a simple se…

Can you define "reifiable" for me? I come across it a fair bit in clojure, but I still don't really understand what the term means.

"reifiable" = "able to be reified", where "to reify" means "to make something abstract concrete or real".

So, for example, Scheme's call/cc function reifies continuations- it take a continuation, an abstract control-flow concept, and turns it into a concrete object that you can pass around and manipulate in code. Therefore, continuations are reifiable in Scheme.

Re: Alan Kay on the misunderstanding of OOP (1998)

#36
post #14

IMO the problem with object-oriented programming is that it turned into the standard curriculum for peoples' first semester of computer science, rather than being yet another interesting concept that advanced programmers would ponder. And the way we handle "the standard CS curriculum" sucks. (In the USA at least.) For example, AP Computer Science requires Java and tries to teach stuff like designing inheritance hiera…

OOP made sense to people who already knew structured programming and understood functional decomposition (what we now call 'refactoring'). Perhaps education should start with that and then justify OOP? I remember reading about the original LOGO experiments; one thing kids do not spontaneously do is break up their monolithic actions into sensible functions.

Functional decomposition != refactoring.

They are two completely different processes.

https://en.wikipedia.org/wiki/Functional_decomposition

https://en.wikipedia.org/wiki/Code_refactoring

Re: Alan Kay on the misunderstanding of OOP (1998)

#37

Earlier quoted context omitted.

OOP made sense to people who already knew structured programming and understood functional decomposition (what we now call 'refactoring'). Perhaps education should start with that and then justify OOP? I remember reading about the original LOGO experiments; one thing kids do not spontaneously do is break up their monolithic actions into sensible functions.

Functional decomposition != refactoring. They are two completely different processes. https://en.wikipedia.org/wiki/Functional_decomposition https://en.wikipedia.org/wiki/Code_refactoring

Breaking up a large functions into smaller functions isn't even (strictly speaking) functional decomposition because not every sub-function might be dependent on the previous function. "Extract function" is a kind of refactoring, but not refactoring itself.

Re: Alan Kay on the misunderstanding of OOP (1998)

#38
post #14

IMO the problem with object-oriented programming is that it turned into the standard curriculum for peoples' first semester of computer science, rather than being yet another interesting concept that advanced programmers would ponder. And the way we handle "the standard CS curriculum" sucks. (In the USA at least.) For example, AP Computer Science requires Java and tries to teach stuff like designing inheritance hiera…

> It's totally inappropriate - most of these students would fail fizzbuzz.

Maybe this is related to the common occurrence of people who can provide stellar answers to interview questions about inheritance hierarchies and object composition... and yet can't pass a basic fizzbuzz style test?

Re: Alan Kay on the misunderstanding of OOP (1998)

#40
I find it interesting that everyone gets so up-beat about the ideology or philosophical debate about objects sending each object messages, hell even not relying to a message one object send you until a later date. Without even thinking about concurrency, state, and hell even the basics such as cyclic loops within a event based system!

Though I keep hearing from Alan and other prominent language designers that we still are holding onto this old 1960 mental model of command and control, or structured design concepts. Even some well spoken people suggest that the whole notion of object's are worthless to programmers because it takes place within the notion of classes and constraints of the machine.

This whole philosophical debate about understanding/miss-understanding/correct usage of OOP is just a complete waste of time.

For what its worth I consider object's simply as a basic level category of procedures and data tied to a namespace. If the category requires state then consider it as a object otherwise its considered a module.

I've seen too many project's that have drunken the cool aid and has resulted in 5-10 level deep inheritance tree's with their own branching logic trying to fit behavior to a specific taxonomy.

Post reply on HN