http://clang.llvm.org/docs/AutomaticReferenceCounting.html
This means we can officially talk about it... now that it's public and OS.
So... ARC... if choosing between ARC and GC... I'd say ARC all the way... would you guys agree?
One thing to clarify, we can talk about the language and compiler aspect of it now. Use of features relating to it in versions of Xcode, Lion, or iOS5 that may or may not exist are still under NDA and can't be talked about. So everyone please keep it on the good side of the line.
Brad Miller
br...@cynicalpeak.com
http://cynicalpeak.com/
I can neither confirm nor deny that any such feature exists in any location other than the LLVM docs. ;)
> --
> You received this message because you are subscribed to the Google Groups "XCodePhoenix" group.
> To post to this group, send email to xcodep...@googlegroups.com.
> To unsubscribe from this group, send email to xcodephoenix...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xcodephoenix?hl=en.
>
We commend Apple for yet another brilliant invention!
Seriously, if it makes the code more succinct without incurring noticeable GC lag and perhaps unacceptable memory overhead on mobile devices running hypothetical operating systems, bravo.
I would be curious, however, to see actual numbers for real programs doing real work when compiled for GC or with ARC. I spent too many years as a static language, manual memory management bigot, only to have my eyes opened finally by languages that were quite fast enough for most of the programs I needed to write. Now I like to see numbers.
However, I would also love to hear developer impressions contrasting the experience of writing for both systems. IS there any appreciable difference between coding with GC and with ARC? Either one gets rid of the reference counting "noise" in the code, which isn't that hard to type but must be scanned by your eyes every time you look at a method.
Brent
On Jun 15, 2011, at 4:41 PM, Jiva DeVoe wrote:
-Troy
I too generally prefer manual memory management due to the curse of GC. Suspect we'll have to wait until it's actually in the wild to see real numbers, but I bet it'll be good.
WRT the code, yes, obviously, you can get rid of your releases, your retains and your autoreleases, you also need to now think in terms of strong references vs weak references. Strong being essentially your traditional retained variables and weak being the equivalent to your old assign properties. The default for all variables is to be strong references... that is, they'll be retained until no one refers to them anymore. If you define a variable as weak, however, it will not be retained. This is important for delegates and so forth. All variables also are now initialized to nil by default and weak references will also be nilled when deallocated. The modifiers used to define your variables are __strong and __weak.
Speaking of variables... when talking about ARC and variables... ARC only affects Objective-C objects. It does not impact any C level pointers allocated with malloc or anything like that.
There's also an additional modifier of __unsafe_unretained which is like weak, but is not zeroed when deallocated.
Variables returned through a parameter that must be autoreleased can also use an __autorelease storage modifier. Mainly you'd use this in cases where you might be doing something like returning an NSError ** or something.
ARC also adds a language construct of @autoreleasepool which works similarly to @synchronized or @try/@catch. It allows you to define a block of code which has it's own autorelease pool.
I suspect for those of us who are used to doing manual memory management, we'll have a lot of discussion about where ARC is inserting it's releases and retains... I think this is interesting from a "this is how it works" perspective... I'm not sure if that'll be helpful or harmful in terms of learning it though, since at the end of the day, you'll want to probably forget about retain and release and change your thinking to strong/weak/autoreleased.
On Jun 15, 2011, at 5:52 PM, Brent Rowland wrote:
FLOORED. Completely & utterly floored. TouchJSON benchmarks: 2000000 iterations. Old code. 22.5846 secs. ARC code: 16.9997 secs
Now, you're not always going to see that much of a speed-up. TouchJSON is friendly for some of the optimization that can be done since it has very heavy accessor use due to parsing and storing the values. But it does show what can happen.
I think I've mentioned once or twice in the past that I hate GC and won't touch it with a 10 foot pole. I'm fully embracing ARC and it will be used everywhere once it's feasible.
Brad
Brad Miller
br...@cynicalpeak.com
http://cynicalpeak.com/
My jab at Apple was primarily because of the list of "innovations"
announced recently that duplicate the accomplishments of their
ecosystem after only recently scolding Samsung for being such a
copycat.
I find it regrettable that now Apple has 3 different memory management
systems in the language. One of the things I hate about Delphi is the
accumulated crud it's dragging around and the associated
inconsistencies. Of course, Objective-C has its C legacy too, but
sometimes it's possible to ignore the worst parts of that or wrap it
up nicely.
I love the automatic nilling of weak references. I dunno how expensive
that is, but it smells like great engineering along the lines of
non-fragile instance variables!
Brent
Obj-c does have the 3 memory models right now, but in a practical sense it's only going to be one. There's no good reason to be using GC at this point and I wouldn't be shocked to see it deprecated in the next couple of years. While I don't think they'll get rid of the current manual memory system, it's use will drop down to niche uses. For the majority of your project you'll use ARC and maybe turn it off for manual if you find some weird edge case.
Brad
Brad Miller
br...@cynicalpeak.com
http://cynicalpeak.com/
On Wed, 15 Jun 2011 19:05 -0700, "Brad Miller" <brad...@gmail.com>
wrote:
Seth
sd...@cornell.edu
Anyone know where in the LLVM stack the ARC logic lives?
Brent
Sent from my iPad
It was also pre-iPhone that it was developed. I remember hearing about them working on GC back as far as WWDC 2003. So there might have been a little bit of thinking that the GC overhead didn't really matter on the desktop.
Brad
> Why did they introduce GC first, and wait to introduce ARC until later?
Most likely because they didn't yet have the compiler technology (LLVM and Clang) that would allow them to implement it soundly. ARC is built on top of the same logic used by the static analyzer, which can already warn you about potential memory leaks in manually managed memory.
--
Brian Webster
bweb...@mac.com
Brad
> I am using __weak in a couple places.
>
> I am only getting the warnings when building a release build targeting
> mac 64-bit.
>
> (I have a project with both mac and iOS targets )
>
> First noticed when building a profile scheme which had the release
> build set.
>
> It runs ok - should I be worried about it?
>
> What does fragile abi mean ?
The non-fragile ABI allows for things like changing the ivars of a superclass without breaking already compiled subclasses (among other things). It's only supported on 64-bit on the Mac though, because of backwards compatibility concerns which didn't allow them to support it on existing 32-bit architectures.
I'm betting your release build is probably set to build universal as 32 and 64 bit (unlike debug, which typically only compiles the native architecture of your dev machine, i.e. 64-bit only), so that may explain why it's complaining at you now that you've changed to doing a release build. If you want to use ARC on the Mac, I'm pretty sure you'll have to drop 32-bit support to do so. You can change the targeted architectures in the build settings for your target in Xcode.
--
Brian Webster
bewe...@gmail.com
Yeah, what he said. 32-bit is dead now on the mac. Really only effects a couple models that are 6 years old now.
Also if you're targeting 10.6 or iOS4 you need to change the __weaks to __unsafe_unretained and remember to zero out your references in dealloc like you always have.