Hacker News new | ask | show | jobs
by DonHopkins 2584 days ago
I think there's a big difference between not understanding the message, and not understanding the data (a message parameter).

When they get an unrecognized message, Objective C objects call their doesNotRecognizeSelector method, and Smalltalk objects call their doesNotUnderstand method.

And the object sending the message can first check with respondsToSelector in Objective C or respondsTo in Smalltalk, before sending the message.

But validating and sanitizing input parameters is a totally different thing than handling unknown messages, orthogonal to object oriented programming.

1 comments

Hm, I don't see how they are totally different and orthogonal.

Objects and messages are kinds of types. Types can have constraints and conditions and there is all sorts of nuance.

Difference, yes. But completely different? No... when designing a system there is a lot of freedom in where to draw the shapes of the system, how much information do we contain in the objects themselves, a hierarchy or inside parameters.

"Stringy interfaces" is one extreme. There are many others.

I think you're barking up the wrong class hierarchy, trying to reformulate objects, messages and parameters as abstract data types. Alan Kay has been quite clear about his opinion that “Abstract Data Types” is not OOP.

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

>One of the things I should have mentioned is that there were two main paths that were catalysed by Simula. The early one (just by accident) was the bio/net non-data-procedure route that I took. The other one, which came a little later as an object of study was abstract data types, and this got much more play.

>If we look at the whole history, we see that the proto-OOP stuff started with ADT, had a little fork towards what I called "objects" -- that led to Smalltalk, etc.,-- but after the little fork, the CS establishment pretty much did ADT and wanted to stick with the data-procedure paradigm. [...]

>(I'm not against types, but I don't know of any type systems that aren't a complete pain, so I still like dynamic typing.)

>OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.

https://computinged.wordpress.com/2010/09/15/alan-kay-on-mot...

>If you are “setting” values from the outside of an object, you are doing “simulated data structure programming” rather than object oriented programming. One of my original motivations for trying to invent OOP was to eliminate imperative assignment (at least as a global unprotected action). “Real OOP” is much more about “requests”, and the more the requests invoke goals the object knows how to accomplish, the better. “Abstract Data Types” is not OOP!

https://news.ycombinator.com/item?id=10967103

>An interesting historical note is that the two inventors of Simula had completely different views of what they were doing and how it should be used for programming. Dahl was brilliant and conservative, and later wrote papers about using class definitions to make Abstract Data Types (and that is how a lot of so-called OOP programming is done today). Nygaard on the other hand was quite a wonderful wild man and visionary -- beyond brilliant -- and was into the abstract "simulate the meaningful structures" idea. Dahl was trying to fix the past and Nygaard was trying to invent the future.

http://worrydream.com/EarlyHistoryOfSmalltalk/

>"Object-oriented" Style

>This is probably a good place to comment on the difference between what we thought of as OOP-style and the superficial encapsulation called "abstract data types" that was just starting to be investigated in academic circles. Our early "LISP-pair" definition is an example of an abstract data type because it preserves the "field access" and "field rebinding" that is the hallmark of a data structure. Considerable work in the 60s was concerned with generalizing such structures [DSP *]. The "official" computer science world started to regard Simula as a possible vehicle for defining abstract data types (even by one of its inventors [Dahl 1970]), and it formed much of the later backbone of ADA. This led to the ubiquitous stack data-type example in hundreds of papers. To put it mildly, we were quite amazed at this, since to us, what Simula had whispered was something much stronger than simply reimplementing a weak and ad hoc idea. What I got from Simula was that you could now replace bindings and assignment with goals. The last thing you wanted any programmer to do is mess with internal state even if presented figuratively. Instead, the objects should be presented as sites of higher level behaviors more appropriate for use as dynamic components.

https://medium.com/@richardeng/goos-is-looking-at-it-from-th...

>GOOS is looking at it from the perspective of Abstract Data Types. In Alan Kay’s conception of OOP, instead of static structures that are easy to reason, aliasing gives you dynamic systems of collaborating objects that are endlessly flexible and scalable, just like in nature’s biological systems of cells or the Internet of web servers. Proponents of ADT-style thinking, who use languages like C++ and Java, can’t imagine such complex systems, or they’re afraid of them.

http://mythz.servicestack.net/blog/2013/02/27/the-deep-insig...

>Where the big missing piece lacking in mainstream typed OO languages today is:

>The big idea is “messaging”

>He advocates focus should instead be on messaging and the loose-coupling and interactions of modules rather than their internal object composition:

>The key in making great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be.

>And finds static type systems too crippling:

>I’m not against types, but I don’t know of any type systems that aren’t a complete pain, so I still like dynamic typing.

>Other popular languages embracing Smalltalk’s message-passing and late-binding and having implemented its message-based doesNotUnderstand construct include: forwardInvocation in Objective-C, method_missing in Ruby and more recently noSuchMethod in Google’s Dart.

https://queue.acm.org/detail.cfm?id=1039523

>Some people are completely religious about type systems and as a mathematician I love the idea of type systems, but nobody has ever come up with one that has enough scope. If you combine Simula and Lisp—Lisp didn’t have data structures, it had instances of objects—you would have a dynamic type system that would give you the range of expression you need.

>It would allow you to think the kinds of thoughts you need to think without worrying about what type something is, because you have a much, much wider range of things. What you’re paying for is some of the checks that can be done at runtime, and, especially in the old days, you paid for it in some efficiencies. Now we get around the efficiency stuff the same way Barton did on the B5000: by just saying, “Screw it, we’re going to execute this important stuff as directly as we possibly can.” We’re not going to worry about whether we can compile it into a von Neumann computer or not, and we will make the microcode do whatever we need to get around these inefficiencies because a lot of the inefficiencies are just putting stuff on obsolete hardware architectures.

https://news.ycombinator.com/item?id=19416424

>"I'm not against types, but I don't know of any type systems that aren't a complete pain, so I still like dynamic typing.)"

>That's probably more controversial here than his views on OO.