
Kay on the Meaning of "Object-Oriented Programming" - fogus
http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en
======
raganwald
I like the notation "<-" instead of "." Here's why: "<-" looks like sending a
message. "." looks like a scoping construct.

Thus, to my brain, "." implies synchronicity: Invoke this function and
continue with the result, it's just that the language implementation will do
some fiddly stuff to look up the function's implementation in an inheritance
hierarchy at run time.

Whereas "<-" implies asynchronicity: Send this message to this independent
entity that has its own memory, processor, whatever. If you need a reply, send
a continuation along with it, a'la current Javascript style.

~~~
arethuza
I've felt for a long time that the tendency to equate "sending a message" and
"calling a function/method" has caused a lot of problems - one is more like
IPC/RPC and the other is something that happens within the local context
(process/thread/etc.).

~~~
pacala
sending a message = piping

sending a message with callback = continuation passing style

~~~
arethuza
I think the Transputer/Occam and Google Go have a better approach where they
were influenced by Hoare's CSP:

[http://en.wikipedia.org/wiki/Communicating_sequential_proces...](http://en.wikipedia.org/wiki/Communicating_sequential_processes)

------
russell
Kay mentions the Burroughs B5000. Boy you have to be an old timer to have
worked on that. I did some Algol programming on the B6500, the next
generation. They were stack machines, but what was interesting was that the
memory words were typed in the B6500 and on. IIRC, the add instruction was not
typed as it is in nearly all other machines, but it did a integer add or
double add based on the tag bits of the operands. Wikipedia has a good
article, <http://en.wikipedia.org/wiki/Burroughs_large_systems>

~~~
arethuza
I think the Burroughs CANDE shell was by far the worst user environment I have
every used on _any_ system - the only nice thing (at least for Tron fans)
being at least things were being fed to the MCP:

<http://en.wikipedia.org/wiki/Burroughs_MCP>

~~~
russell
In those days everything was terrible. We had to deal with 360 JCL an similar
abominations. You couldnt dignify them with the term shell. It was timesharing
and ultimately Unix that liberated us.

------
cconroy
What does Kay mean by late-binding? ... not the dynamic binding of overriding
methods in a subclass or virtual functions (C++)? The last paragraphs compared
smalltalk with lisp in this respect.

~~~
igrekel
Not being in his head, I'll try to guess from what I know of smalltalk. It
means the actual binding of a message to the method to execute is done only
when the message is received. TOo give you an idea, you may associate some
code to specific messages to an object at runtime, you may also implement
doesNotUnderstand and decide how to handle messages who don't have
corresponding methods (forward it to another object, have some special
behavior, create the method on the fly as needed).

~~~
IgorPartola

      Foo.counter = 0;
      Foo.prototype.handle = function(message, data) {
        if (message == 'bar' && Foo.counter < 3) {
           return this.bar(data)
        }
        else {
          throw "I forgot about 'bar'."
        }
        Foo.counter++;
      }

~~~
igrekel
Not too sure about what the point is, or maybe it is just my limited knowledge
of javascirpt that's playing me tricks. In any case I didn't know of a
prototype.handle function and can't figure out any way for it to intervene in
the usual way of calling functions on an object.

var f=new Foo()

f.bar() //Just says that f.bar is undefined and therefor not a function

//If I add

f.bar=function(something){return "nothing"}

//Calling

f.bar("ABC") //Many times always answers "nothing"

~~~
gliese1337
There isn't such a function built-in, though something like it (a
doNotUnderstand functionality to call a default function instead of throwing
an error if the requested field isn't found on an object) has been proposed as
a future addition to the JavaScript standard.

IgorPartola's example code won't intervene in the usual function-call process;
rather, it provides a tacked-on means of simulating message sending behavior
that _ought_ to be included in the language's syntax under Kay's definition of
OO. With this convention, you'd never call bar(), or any other method,
directly; you'd call handle to send a 'bar' message to the object instead.
Then, if you send a message the object doesn't understand, handle() can route
it properly.

~~~
justincormack
Lua has this, with metatables that can set methods to handle undefined stuff.
It is actually very useful and you can do a lot with it.

------
rickmode
Sounds like Erlang is close to Dr Kay's notion of OOP - though my Erlang-fu is
not strong enough to know if it has polymorphism.

~~~
thesz
Yep.

I should note that OO means "objects having state".

You can send identical messages to different processes and they can respond
with (structurally) same answers, so Erlang is polymorphic enough to be OO.

 _"Erlang might be the only object oriented language because the 3 tenets of
object oriented programming are that it's based on message passing, that you
have isolation between objects and have polymorphism":_
<http://www.infoq.com/interviews/johnson-armstrong-oop>

~~~
rudiger
Erlang also has support for _extremely_ late binding method dispatch. It's a
bit tongue-in-cheek to call it a lightweight object-oriented programming
language, though. I wouldn't use processes as objects in practice. My
successful Erlang programs usually use fewer and more long-lived processes
than I use objects in C++, Java, and Objective-C.

~~~
thesz
>My successful Erlang programs usually use fewer and more long-lived processes
than I use objects in C++, Java, and Objective-C.

I think I could attribute it to lack of tools in C++, Java and Objective-C.
You basically forced to use objects for almost everything (especially in
Java).

In Erlang, however, you have tuples, higher-order functions and pattern
matching, among with process creation and message send/receive. They are
different from processes (and objects) and that's where your feeling come
from.

------
seles
What is wrong with data?

~~~
cousin_it
Nothing! The extreme opposite to Smalltalk in this respect is the APL/J/K
family of languages where everything is expressed as mathematical operations
on multidimensional arrays of data. For example, a K programmer wouldn't use
an array of rectangles, preferring to have separate arrays of widths and
heights. It's a very eye-opening programming style in its own right, and a
curious programmer would do well to get acquainted with both.

Here's a nice page of "K finger exercises":
<http://kx.com/technical/contribs/eugene/kidioms.html> . To someone who grew
up on modern OO languages, it's unbelievable how much K manages to accomplish
in one line of code.

~~~
silentbicycle
There is a trial version of q (a newer k variant) at the Kx website, and a
couple of us are also working on Kona, an ISC-licensed k-like language, at
<http://github.com/kevinlawler/kona> .

The k way of doing things is indeed eye-opening. There is some documentation
for Kona on its github wiki page, and Hakan has an extensive set of k
resources at <http://www.hakank.org/k/>.

------
lepton
We should really link to <http://www.purl.org/stefan_ram/pub/doc_kay_oop_en>
which is still valid and may outlast fu-berlin.de.

~~~
hercynium
Nope, that's down for me, too. However, I managed to snag something on Coral:

[http://userpage.fu-
berlin.de.nyud.net/~ram/pub/pub_jf47ht81H...](http://userpage.fu-
berlin.de.nyud.net/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en)

~~~
InnocentB
I get a 403 from that link too...I've actually never seen that from Coral
before, anyone know what's going on?

------
elcron
aeohu

