Monday, December 10, 2007

Page 2 (OK, I'm not going to keep the page numbering thing going after this)

As much as I'm really enjoying Objective-C 2.0 (with GC: a return to ref counting is just too retro for me even though I've used that memory management scheme for many years, though see the footnote), there are a few aspects of the language that definitely feel 'wrong' after years of Java.

Not too many, but a few.

One of the things that bug me a little is the lack of true constructor syntax, and the non atomicity of object instantiation. It's a little odd, to say the least, that the state of an object is forever threatened by the -init message (assuming something in the receiver's class hierarchy does something on receipt). While all imperative programming is reliant on calls happening intentionally, and spurious messages are bad no matter what, this seems like a bit of an extreme hole, with limited/unsatisfactory defences available.

Ignoring this, -init does allow you to do some potentially interesting things (like returning a completely different instance than the receiver), though the boiler plate code for an init definition is something of a constant price to pay for what seems like a seldom used flexibility.

----
Footnote:
Though I was forced back into this world upon the discovery that the brand new Interface Builder 3.0 is still built non-GC, and therefore any plug-ins need to be built this way. Thankfully my intended plug-in was rather simple!

No comments: