News for hackers. Stuff that matters.
Re:Why OO Sucks by Joe Armstrong (2000) by jdsully on Monday April 22, 2019 @12:46AM (#19716594)
Objective-C is much closer to true object orientation than C++, but IMO Apple neutered it by having the program crash if there was no message handler.
Re:Why OO Sucks by Joe Armstrong (2000) by mpweiher on Monday April 22, 2019 @02:02AM (#19716872)
It crashes only if you let it.

a) The crash is from the default unhandled exception handler, which will send a signal to abort. So if you just want to crash, you can either handle that particular exception or install a different unhandled exception handler

b) An object gets sent the -forwardInvocation: message when objc_msgSend() encounters a message the object does not understand. The exception above gets raised by the default implementation of -forwardInvocation: in NSObject.

    o := NSObject new.
    o class
    -> NSObject
    n := NSInvocation invocationWithTarget:o andSelector: #class
    n resultOfInvoking class 
    -> NSObject
    o forwardInvocation:n 
    2019-04-22 07:49:12.339 stsh[5994:785157] exception sending message: -[NSObject class]: unrecognized selector sent to instance 0x7ff853d023c0 offset: {
(This shows that -forwardInvocation: in NSObject will raise that exception, even if the NSInvocation is for a message the object understands)

If you override -forwardInvocation:, you can handle the message yourself. In fact, that is the last-ditch effort by the runtime. You will first be given the chance to provide another object to send the message to ( - (id)forwardingTargetForSelector:(SEL)aSelector; ) or to resolve the message in some other way, for example by installing the method ( + (BOOL)resolveInstanceMethod:(SEL)sel; )[0].

Cocoa's undo system is implemented this way[1], as is Higher Order Messaging[2][3]

[0] https://developer.apple.com/documentation/objectivec/nsobjec...

[1] https://developer.apple.com/documentation/foundation/nsundom...

[2] https://en.wikipedia.org/wiki/Higher_order_message

[3] https://github.com/mpw/HOM/blob/master/HOM.m

Re:Why OO Sucks by Joe Armstrong (2000) by matwood on Monday April 22, 2019 @07:32AM (#19718054)
Back when I wrote a lot of obj-c is when I really 'got' message passing vs. a function call. I miss obj-c, but everyone wants to move on to Swift.
Re:Why OO Sucks by Joe Armstrong (2000) by dragonwriter on Monday April 22, 2019 @09:13AM (#19718619)
Wasn't the design decision (and implementation) involved in place log before Apple had anything to do with it?
Re:Why OO Sucks by Joe Armstrong (2000) by jdsully on Monday April 22, 2019 @12:21PM (#19720165)
NextStep adopted it but did not invent it. Once Apple acquired NextStep and released OS X they were the only major company supporting it and had defacto control over the language.

The complaint I have is with NSObject which can be blamed on Next Step. Although another comment pointed out I just didn’t know about a workaround.

Re:Why OO Sucks by Joe Armstrong (2000) by dragonwriter on Monday April 22, 2019 @12:26PM (#19720211)
There were two different major mutually-incompatible “flavors” of Objective-C (my first book on Objective-C covered both, and my first Objective-C programming was done on a NeXTcube), one of which originated at NeXT (NextStep was the OS that was NeXTs last major surviving product after they dropped hardware, not the company.)