3 ms·
I like Objective-C too. It's just C with a very good lightweight abstraction layer for modeling GUI apps. I'm enough of a purist to think Obj-C 2.0 (introduced
by pavlov 3y ago
I like Objective-C too. It's just C with a very good lightweight abstraction layer for modeling GUI apps.
I'm enough of a purist to think Obj-C 2.0 (introduced around 2007 at the same time as iOS) was mostly a mistake. In old Objective-C, it was absolutely clear when you were sending a message. You couldn't mistake a line of C code for an Obj-C message call.
But Obj-C 2.0 lets you use the same syntax for message calls and struct member access, as in:
foo.view.bounds.size.width
Two of these dots are expensive virtual message calls. The other two are practically free stack pointer offsets. It's not in good C spirit to introduce this kind of confusion about performance impact. (However it's very much in the worst C++ spirit of frivolous overrides.)
And the benefits were mostly meaningless because the old way (which still works) was barely any longer to type, especially with IDE autocomplete:
[[foo view] bounds].size.width
- mpweiher 3y agoYep. And what's even worse is that the semantics are muddled. foo.view.bounds.size.width = 200; This will not set the width of the view to 200.
- another2another 3y ago>But Obj-C 2.0 lets you use the same syntax for message calls and struct member access I'm in 100% agreement, you should never hide the message passing syntax, and am not a fan of this feature. Alas it was probably introduced as a sop to those people that are constantly complaining about the syntax, and in the process made the language worse ergonomically, not better.