<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Important Shock]]></provider_name><provider_url><![CDATA[https://importantshock.wordpress.com]]></provider_url><author_name><![CDATA[Patrick Thomson]]></author_name><author_url><![CDATA[https://importantshock.wordpress.com/author/importantshock/]]></author_url><title><![CDATA[Objective-C 2.0]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>As many of you know, Apple is releasing the new incarnation of Objective-C (creatively dubbed Objective-C 2.0) along with XCode 3.0 and Leopard. Though much of it is hidden under Apple&#8217;s elaborate nondisclosure agreements, people like <a href="http://andymatuschak.org/articles/2006/08/27/clues-to-objective-c-2-0">Andy Matushack</a> and <a href="http://theocacao.com/document.page/288">Scott Stevenson</a> as well as <a href="http://www.informit.com/articles/article.asp?p=665128&amp;seqNum=1&amp;rl=1">other</a> sites have uncovered more information from the ObjC mailing lists and repositories than the meager scraps of info that <a href="http://www.apple.com/macosx/leopard/xcode.html">Apple released</a> on their website.</p>
<p>Since I can&#8217;t give any new information about this, I&#8217;ll just list my opinions, then brace for the reaming I&#8217;ll receive in the comments.</p>
<p>Disclaimer: Apple may change all of these things. This post is naught but conjecture heaped upon conjecture.</p>
<p><!--more--></p>
<p><strong>The Good</strong></p>
<p>1. The <code>foreach</code> loop.<br />
It&#8217;s simple, but makes lives easier when we don&#8217;t have to mess about with NSEnumerators for standard iteration. Here&#8217;s how one iterates through an <code>NSArray</code> of objects:<br />
<code><br />
for (id tempString in theArray)<br />
{<br />
// do things here<br />
}<br />
</code><br />
It&#8217;s very reminiscent of the Python for loop:<br />
<code><br />
for ii in someList:<br />
# do things here<br />
</code><br />
It&#8217;s also much easier to understand immediately than the Java 5.0 foreach loop, which inexplicably uses a colon to indicate &#8220;in&#8221;:<br />
<code><br />
for (Object ii : someSet) {<br />
// do things here<br />
}<br />
</code><br />
This is a simple thing that I will appreciate very much; it saves me from messing about with standard C for loops or NSEnumerators. I&#8217;m glad they picked the Pythonic syntax, as it&#8217;s far more readable.</p>
<p>2. Garbage collection.<br />
To be honest, I know next to nothing about how garbage collection works. I do know that though memory management in Cocoa is much better than in C++, garbage collection is always welcomed; if they make it both quick to use yet optional (like the <a href="http://www.digitalmars.com/d/">D language</a> has), it seems everyone will be happy.</p>
<p>3. More explicit support for protocol methods.<br />
Now, instead of blindly hoping that I remembered to implement all the methods for a protocol, I can be warned by the compiler that I need to implement certain ones. By using the <code>@required</code> and <code>@optional</code> directives, one can specify that certain methods must be included in classes that implement a given protocol. This seems like a step in the right direction &#8211; after all, what&#8217;s the point of implementing protocols if you don&#8217;t remember to code the correct methods?</p>
<p><strong>The Okay, I Guess</strong></p>
<p>[This section was changed, as what I previously had here was not new to the language.]</p>
<p>1. Official support for attributes on method calls.</p>
<p>According to <a href="http://www.quepublishing.com/articles/article.asp?p=665128&amp;seqNum=3&amp;rl=1">this article</a>, we will be able to specify that methods are unavailable/deprecated/what have you &#8211; inside the code:<br />
<code><br />
- (void) foo __attribute__ ((deprecated)) __attribute__ ((unavailable));<br />
</code><br />
The above was taken directly from the repository, so it should be canon.<br />
I don&#8217;t really know what to think about this; though news about method deprecation would be nice, perhaps Java&#8217;s @deprecated JavaDoc tag is more elegant.<br />
<strong>The (Hideously) Ugly</strong><br />
1. Properties<br />
I was around halfway through a really venomous diatribe on why properties are such a bad idea when I remembered <a href="http://www.stuffonfire.com/">David Young</a>&#8216;s entry <a href="http://www.stuffonfire.com/2006/12/08/does-objective-c-really-need-properties/">Does Objective-C Really Need Properties</a>? He provides a far clearer case against them than I ever could; go read the article. In fact, his article pretty much supersedes mine. *cries*</p>
<p>We <strike>may</strike> will learn new things about ObjC 2.0 in the future, things that may put a spring in our steps and smiles in our hearts. But right now, I am without both &#8211; I&#8217;m afraid that Apple went overboard with the syntactic sugar.</p>
<p>Feel free to tell me how wrong I am in the comments.</p>
]]></html></oembed>