Kay on the Meaning of "Object-Oriented Programming"
userpage.fu-berlin.de
userpage.fu-berlin.de
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.
This was the language that taught me what Kay was talking about.
sending a message with callback = continuation passing style
http://en.wikipedia.org/wiki/Communicating_sequential_proces...
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++;
}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"
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.
http://carcaddar.blogspot.com/2009/04/closure-oriented-metap...
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...
I've a lot of respect for Dr. Kay, but history has shown him to be wrong on this point: strong static typing and binding things as early as possible is how robust systems are built and how errors are minimized.
However I won't doubt that the Smalltalk approach is probably right for its original intended purpose (exploratory or didactic programming).
Huh? What about Erlang?
For a good overview, check "Gradual Typing of Erlang Programs: A Wrangler Experience " (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.160....) and/or "Practical type inference based on success typings" (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.62....).
Could you expand on this? I don't see how late binding is incompatible with the robustness that static typing provides. In a traditional (C/++/#/Java) OOP setting, virtual methods and dynamic method dispatch allow for late-binding of method names to behavior based on run-time type specializations, but you still have the static compile-time guarantee that a method with the appropriate name and type signature will exist. This seems to me like it has the same robustness as an early-bound model, bounded only by the sophistication of the type system. Do you consider it qualitatively less late-bound than the message-passing paradigm, or am I missing something?
The rough equivalent of a process changing from one class to another would be tail-calling into a different recieve { (set of pattern-matching expressions) } function. Instead of changing classes, it looks more like a state machine.
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
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.
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.
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/.
Although you would need to provide dynamic scope or pass the first argument as self for it to truly behave like a normal method.
The simplicity of this model is appealing to me but I do not know if any existing languages use it?
http://userpage.fu-berlin.de.nyud.net/~ram/pub/pub_jf47ht81H...