12 ms·
iOS 5 has garbage collection. Here comes MacRuby/iOS?
- schrototo 15y agoiOS 5 doesn't have garbage collection, it has a new compiler-level feature called Automatic Reference Counting which does pretty much what you think it does. It's basically retain/release without you having to explicitly write retain/release instructions. (I don't think I'm violating any NDAs here, since ARC was up pretty big on one of the slides at the keynote. In any case, anybody who cares about this stuff is either at WWDC or at least has a dev account and has been pouring over the beta docs since they've gone online.)
- jcnnghm 15y agoI think this is actually a bigger deal from a developers perspective than most of the other announcements. Since it's a compiler feature, does anyone know if it's compatible with older os releases? Once you're familiar with the manual memory management conventions, it's not difficult, but this should make iOS development more approachable.
- schrototo 15y ago"ARC is supported in Xcode 4.2 for Mac OS X v10.6 and v10.7 (64-bit applications) and for iOS 4 and iOS 5. (Weak references are not supported in Mac OS X v10.6 and iOS 4)." But how about looking at the docs yourself?
- jcnnghm 15y agoAren't they behind a password/NDA wall? Perhaps I didn't see that information when I was looking at it?
- schrototo 15y agoI'm sorry, I didn't mean to be snarky. (Although if you're not a member of the dev program, I don't see why you care about this information?)
- prodigal_erik 15y agoAny new platform that isn't ultradoomed is interesting. I might have been waiting for iOS development to become less brittle before getting involved (that is, if their policies towards developers and users weren't so repellent).
- themgt 15y agoIsn't "automatic reference counting" just a specific type of "garbage collection"? But yes, I think this feature really slipped through the cracks in the announcements I've seen so far (even Ars seemed confused about it)
- jcnnghm 15y agoI think this is done at compile time, so it wouldn't be considered garbage collection.
- themgt 15y agoThe compiler is LLVM though, "By enabling ARC with the new Apple LLVM compiler", which begins to blur the difference
- jcnnghm 15y agoI don't think that makes much difference, as long as it's performed at compile time.
- ori_b 15y agoLLVM is being used as a static compiler. There is no LLVM virtual machine - the compiler emits native machine code.
- themgt 15y agoMacRuby does support AOT compilation, although I don't think it's a very production-ready feature yet and would likely be incompatible with a fair percent of existing ruby code
- chc 15y agoThis isn't in MacRuby — it's in Objective-C. And it's explicitly distinct from garbage collection. This is an alternative to garbage collection that has generally been considered kind of impractical. (And MacRuby's AOT compilation works pretty well from what I've seen.)
- aaronharnly 15y agoARC is touted on this public page: https://developer.apple.com/technologies/ios5 https://developer.apple.com/technologies/ios5
- schrototo 15y agoThat's a... peculiar choice of icon. edit: ah, now I get it. Cute.
- zyb09 15y agoI don't get it :( please explain.
- StavrosK 15y agoIt's an arc.
- sanswork 15y agoWhen electricity moves through the air between two points like that its called an arc. (look up electric arc on youtube for examples)
- jannes 15y agoOh, so it isn't a visualization of how ARC works. It's just an image of something else that coincidentally has the same name. I would've never figured that out. Thanks.
- maximilianburke 15y agoI'm not sure why you would say this isn't garbage collection. It performs automatic management and reclamation of resources without programmer intervention. It doesn't operate like the GC's of the JVM or .NET CLI, but then neither to the GCs for other languages like Lua, Python, or Perl.
- dialtone 15y agoPython has a proper GC to remove cycles in reference counting, it's just not the "main" one. http://docs.python.org/library/gc.html http://docs.python.org/library/gc.html Since the collector supplements the reference counting already used in Python, you can disable the collector if you are sure your program does not create reference cycles. Automatic collection can be disabled by calling gc.disable().
- drewcrawford 15y ago> I'm not sure why you would say this isn't garbage collection. Because it isn't. Garbage collection is something that happens at run time by a garbage collector via an algorithm like mark-and-sweep, tri-colour marking, etc, and as a block of code that's called at runtime it A) has a lot of information about your program and B) has a nontrivial performance impact. Unfortunately I can't talk specifics (stupid NDA), but schrototo has said that it's a compiler-level feature, which would automatically disqualify it as being a bona fide garbage collector. Speaking generically, any static feature is going to a great deal less powerful than its dynamic equivalent. Thinking of compile-time memory management as garbage collection is not just a leaky abstraction, it's a broken water main flooding into the street. Think less "auto pilot" and more "cruise control". You still have to understand the accelerator and the break, you just don't have to use them as much.
- maximilianburke 15y agoA garbage collector doesn't need to use an algorithm like mark-and-sweep, or two space copying. It can be something as simple as a system that scans a block of memory looking for any sequence of bytes that appears to be a pointer into managed memory. You don't need special compiler support or extra program knowledge for garbage collection -- conservative collectors can be added to any language, like using the Boehm-Demers-Weiser GC with C or C++. Automatic garbage collection doesn't even require a garbage collector -- the monolithic piece of code that performs the scanning and reclamation of objects -- it simply requires freeing the programmer from the task of managing the storage of an object. Fancy collector algorithms are meant to improve throughput and latency -- you could definitely create an implementation of Java that uses automatic reference counting but you'd be searching for something faster really quickly. If I have a language where I create a number of managed objects and the compiler's escape analysis determines that these objects never leave the function's scope and so changes them to be an alloca then you would have garbage collection without involving a garbage collector. Again, if that's what automatic reference counting is as sold by Apple then I'd consider it to be garbage collection.
- ori_b 15y agoThis is probably going to hurt performance a whole lot more than proper GC, because now the compiler throws in a whole bunch of retain/release statements where they aren't really needed. Unless they're doing some pretty strong analysis to remove redundant reference operations.
- dirtyaura 15y agoI think it's still easier to ensure performant code as reference counting is more deterministic than GC. I assume you can turn off ARC for compilation unit if you want, so performance critical code can be manually managed.
- ori_b 15y agoNaieve reference counting incurs a bus lock across all processors on every assignment, more or less. That's quite painful.
- gonzo 15y agoHow many processors (cores) do most iOS devices have? GC is still supported on MacOS X.
- cpeterso 15y agoOne core, but the Apple A5 in the iPad 2 and iPhone 4GS/5 (the flagship devices for iOS 5) has two cores.
- kstenerud 15y ago95% of code can run an order of magnitude slower than "optimal" with no discernable degradation of the user experience. If a bus lock degrades your performance too much, either change your algorithm, or isolate that section of code and do it in another language that doesn't suffer the same performance issues.
- rsl7 15y agoAlso autorelease only applies to NS objects, not plain C data.
- adriand 15y agoThe arguments over performance, compiler features, and the definition of garbage collection aside, I'm curious what members of the HN community think about the chances of Ruby becoming an iOS-approved programming language. It seems as though the groundwork has been laid, and from an aesthetic perspective, Ruby seems like a nice fit for Apple. Plus, it's not Python, which is arguably Google's baby.
- jcnnghm 15y agoI think it's a certainty that it's a feature in the pipeline. The only question is when it will happen, which is really a function of performance and memory usage. I suspect this is a big step forward.
- nupark2 15y agoI don't think it's quite the certainty you're making it out to be. Ruby is a step sideways, if not backwards, from Apple's current strategy. We're far more likely to see an Objective-C without the C than we are to see Ruby as a first class development target for iOS.
- skidooer 15y agoRuby essentially is Objective-C without the C. If Apple was looking for a language that moved away from the low level C, what benefit would an "Objective" language bring over MacRuby, which is already using the native Objective-C system frameworks?
- nupark2 15y agoA non-runtime type system. First class familiar Objective-C-style messaging and block syntax. Stable, mature, well defined language invariants on par with Apple's requirements for its own APIs and languages. "Objective-C without the C" would look more like Smalltalk or Strongtalk with a near identical syntax, not Ruby.
- alloy 15y agoAlthough I empathize with your wishes, your article is way too sensationalistic. Let me confirm (I’m not with Apple); MacRuby on iOS has _NOT_ been confirmed.
- alexbell 15y agoAgreed. ARC is not garbage collection, nor is it an indication in any way that MacRuby on iOS is coming.
- nick_urban 15y agoI wonder what effect this will have on HTML5 app development. Would the Ruby developers who are considering building HTML5 apps go for native Ruby instead if given the option?
- alexbell 15y agoThe effect WHAT would will have on HTML5 development? And would ruby developers use ruby if given the option? Somehow, I think so.
- cincinnatus 15y agoHTML5 apps are going to be heavy on JavaScript. It is a matter of personal preference or dislike of JS which is a big factor here. More important though is how performant and tight the app is, I think most developers who are wanting to have the best performance will choose native.
- themgt 15y agoEloy says not confirmed: http://twitter.com/#!/alloy/status/78089941829160961 http://twitter.com/#!/alloy/status/78089941829160961
- davidrupp 15y agoHe didn't say "no". He said "not yes". There's still hope, man! #glassHalfFull
- deleted 15y ago[deleted]
- alloy 15y agoWell, I simply can’t say ‘it will not happen’, because it is open-source software, so for all I know you are currently implementing it. However, I wouldn't hold your breath on someone else stepping up to make this work, because we have been saying this for a while now… C’est la vie.
- alloy 15y agoYeah, sorry to rain on your parade, bro. But these kind of ‘confirmed’ articles, in the end, help nobody. Users will be sad when it doesn’t happen, whereas neither Apple nor the MacRuby team have actually confirmed/promised this. Sorrow all around isn't good publicity. Thanks for the update, though! :)
- uxp 15y agoAutomatic Reference Counting is not Garbage Collection, but it's a start, and can weakly be used as a sort of garbage collection. It is up on iOS5's site page, however, so that part is confirmed for now. http://developer.apple.com/technologies/ios5/ http://developer.apple.com/technologies/ios5/
- alloy 15y agoI’m talking about “MacRuby on iOS 5 - CONFIRMED!!!”.
- justincormack 15y agoYou dont need OS support for gc to do gc in a scripting language. Wax, https://github.com/probablycorey/wax https://github.com/probablycorey/wax which is a Lua binding for UIKit does all the gc for you. The framework just needs to do all the bookkeeping for you behind the scenes.
- prodigal_erik 15y agoWhen the platform's native data structures are explicitly managed but not garbage collected, the language runtime can't just steamroller them, it has to notify the platform about each individually becoming disused. It's the worst of both worlds, you pay for O(n) work to handle garbage as well as not reclaiming memory immediately, and it's worse with an API that takes graphs of first-class objects rather than buffers which happen to contain the bits you want (which are incredibly risky, but the language runtime can handle that once and for all).
- lisperforlife 15y agoDoes this mean that we can write apps that target iPhone and iPad with MacRuby?
- jemeshsu 15y agoNot on topic but anyone knows why Lion comes with Ruby 1.8.7 and not 1.9 branch?
- brianbal 15y agoI hope this is true
- pornel 15y agoI hope this will be better than LLVM Analyzer's warnings about missing retain/release, which in my experience catches most, but not all of missing retains/releases.
- deleted 15y ago[deleted]
- patrickg 15y agoSomeone has made a comment on HN before like this: if the title of a submission is a question, the answer is most likely 'no'.
- sspringer 15y agohttp://www.research.ibm.com/people/d/dfb/papers/Bacon03Pure.pdf http://www.research.ibm.com/people/d/dfb/papers/Bacon03Pure....
- sspringer 15y agoMore important for MacRuby on iOS seems to be the "static" compile option (not functioning yet) see http://bostonrb.org/presentations/102 http://bostonrb.org/presentations/102 (http://vimeo.com/25213324 http://vimeo.com/25213324) @ 32:03 - 32:48 in combination with http://bostonrb.org/presentations/106 http://bostonrb.org/presentations/106 (http://vimeo.com/25232412 http://vimeo.com/25232412) @ 06:15 - 07:40; with this "static" option some Ruby features will not be supported. - Also note @ 05:26 - 05:58 in the first video :-)