| ▲ | 9rx 5 hours ago |
| Absolutely not. It only sends a message. The receiver doesn't have to have a corresponding method and can do with that message what it will. Objective-C is a 'true' object-oriented language, like Smalltalk. |
|
| ▲ | flohofwoe 4 hours ago | parent | next [-] |
| In the end though most of those 'sending a message' actions are just fancy virtual method calls (e.g. an indirect jump), everything else would be much too slow: https://www.mikeash.com/pyblog/friday-qa-2017-06-30-dissecti... IMHO the whole 'message' and 'sending' lingo should be abandondend, the job of objc_msgSend is to look up a function pointer by certain rules. There are no 'messages' involved, and nothing is 'sent'. |
| |
| ▲ | 9rx 4 hours ago | parent [-] | | > There are no 'messages' involved, and nothing is 'sent'. The conceptual difference is significant as an object can respond to messages that it doesn't have a method for. You are, conceptually, just sending a message and leave it up to the object what it wants to do with it (e.g. forwardInvocation:). That is, after all, what sets "object-oriented" apart from having objects alone. Optimizations that can be made under the hood don't really affect the language itself. | | |
| ▲ | MaxBarraclough an hour ago | parent | next [-] | | > That is, after all, what sets "object-oriented" apart from having objects alone. I wouldn't say so, most object-oriented languages don't work like Objective-C/Smalltalk. Today, I think most programmers would agree that inheritance is the defining feature of object-orientation. | | |
| ▲ | 9rx 5 minutes ago | parent [-] | | Okay, that's what sets what was classically known as "object-oriented" apart. Understandably, language evolves. If OO means something different today, what do most programmers call what used to be known as OO? I honestly have never heard anyone use anything else. What did most programmers settle on for this in order to free up OO for other uses? |
| |
| ▲ | flohofwoe 4 hours ago | parent | prev [-] | | > can respond to messages that it doesn't have a method for. Clang produces a warning in that case though (something along the lines of "object might not respond to ..."), I don't think that feature is particularly useful in practice (also because it kills any sort of type safety) :) | | |
| ▲ | kccqzy 2 hours ago | parent | next [-] | | And the reason it’s a warning and not an error (like in C++) is that it’s actually possible that the object can respond to such a message but the compiler doesn’t know about it. | |
| ▲ | 9rx 4 hours ago | parent | prev [-] | | It was incredibly useful in the olden days. The NeXT/Apple ecosystem leaned on it heavily. We have new ways to approach problems nowadays, so it may be fair to say that object-oriented programming is a relic of the past. I mean, it is telling that Smalltalk, Objective-C, and Ruby are the only languages to ever go down that road. Still, if you are using an OO language, then it makes sense to lean into OO features. Otherwise, why not use a language better suited to your problem? |
|
|
|
|
| ▲ | chuckadams 5 hours ago | parent | prev [-] |
| > a 'true' OOP language, like Smalltalk. I guess Simula, which is older than Smalltalk, doesn't get a say. |
| |
| ▲ | 9rx 5 hours ago | parent [-] | | What would it have to say about it? When "object-oriented" was first told, it was said that what defines it is message passing. Simula does not have message passing. It uses function calling. Simula does have objects, but having objects does not imply orientation. |
|