[index]
Objective-C drops messages rather than crashing
cturner, 20240829
--

This morning I read a discussion about some projects on hacker news that are
built in the Objective-C programming language.

While reading, I thought about an aspect of Objective-C that I dislike. It
would have been poor manners to distract from the specific work of those
developers who are using Objective-C with these thoughts by posting in that
forum. Rather, I post the thoughts here.

Objective-C contains a nasty tradeoff: if an object tries to send a message to
another object that does not exist, the message will silently drop with no
crash.

When I first learnt about this, I thought it might be useful, because it would
allow me to skip validation in some situations. But over time I have realised
that you cannot make the decision about what validation you can skip without
hard thinking. The nature of that hard thinking is very similar to the work of
implementing validation. As a result, it brings no benefit to the
conscientious developer. For them, it is most efficient to structure code for
exhaustive validation.

But problems emerge from less conscientious developers. The platform's
tolerance for dropped messages incentivises a style of corner-cutting
development, where the developer makes fair-weather assumptions at every
opportunity. The resulting code appears to work. But regular use of it will
reveal it to be unreliable garbage.

Facetime for ipad seems to be built like this. A well-built video chat app
would contain careful logic to establish and retire network channels, and
filter activity into active channels only. When I have used Facetime, it has
often shown behaviour that suggests it does not do this work. In one
situation, it leaves a call open and continues to respond to key presses,
whilst the video is frozen. In another situation, I dial another user, it
shows as ringing on my end, but I lean later that it did not ring on any of
their devices.

Though I have never seen the code, I guess that Facetime was built using the
fair-weather style.

Early in my career, I worked under the direction of George Oats, who took a
riff on "if it ain't broke, don't fix it" when she said "if it doesn't work,
it's broken."

I think if Facetime crashed hard when it got into these states, the team
responsible for it would not be able to pass it off as complete. That would be
a good thing.

It is possible to develop quality software in Objective-C, and many developers
have done so. This criticism is of its message drop behaviour, the incentives
that this creates, and the work of developers who lean into those incentives.