4 ms·
I don't understood why people think automatic deallocation = garbage collection = slow language. You can have reference counting without garbage collection. It'
by redstripe 16y ago
I don't understood why people think automatic deallocation = garbage collection = slow language. You can have reference counting without garbage collection. It's pretty obvious to a compiler when a variable has gone out of scope and can be dereferenced (and deallocated immediately at 0).
Using a language like obj-c where you have to do memory management manually just seems so archaic after using modern languages. Plus there is strange property duplication syntax, split header/code files, a GUI editor that doesn't easily wire events to code, named parameters, c/smalltalk calls mixed together, etc.. it's just a mess.
In my brief stint using it the whole time I kept thinking this would be so much simpler if I could do it the XYZ language way. Obj-C is a language that you have to try really hard to like. If you have to convince yourself then maybe it's not that good.
- protomyth 16y agoFirst, even the "manual" version of garbage collection (the retain/release) pattern is pretty trivial with Objective-C (more so with the new property syntax). Once you know the rules it was pretty automatic and really didn't cause that many problems. It was more a problem with the "checklist" language comparisons. The "property duplication syntax" (I assume you mean the declare versus synthesis) is there for flexibility and so you can do some pretty good customization to make your classes work better. For OS X, Objective-C now has garbage collection that works pretty well.
- vegashacker 16y agoObjective-C's retain/releasing is only trivial if you're doing fairly simple stuff. Ever create a circular reference with objects? Ugh...
- famfam 16y agoreference counting != "manual garbage collection"
- gte910h 16y ago>Using a language like obj-c where you have to do memory management manually just seems so archaic after using modern languages. That's not an Objective C thing, the language has garbage collection, just it isn't enabled for the mobile platform, for the reason it eats power and memory.
- redstripe 16y agoMy point was that it is possible to have deterministic deallocation without garbage collection. This can be done at compile time. So I don't buy the "eats power" excuse for needing manual memory management.
- gte910h 16y agoNo it's not. For some programs, it is possible to tell, for others, it most certainly is not.
- Zev 16y agoI don't understood why people think automatic deallocation = garbage collection = slow language. You can have reference counting without garbage collection. It's pretty obvious to a compiler when a variable has gone out of scope and can be dereferenced (and deallocated immediately at 0). `[object performSelector:sel];` // where `sel` may be - retain How should the compiler optimize that? Plus there is strange property duplication syntax You don't have to bother with that anymore. The only reason you ever did with iPhone dev is because the iPhone Simulator didn't support the modern runtime. If you only tested on the device, you never had to bother with it. As of LLVM 1.5 (in Xcode 3.2.3) or 2.0 (in 4.0) on 10.6, the compiler can fake enough for runtime support (and only requires @property declarations - no more ivar or @synthesizers): http://www.mcubedsw.com/blog/index.php/site/comments/new_objective-c_features/ http://www.mcubedsw.com/blog/index.php/site/comments/new_obj... named parameters Objective-C doesn't have named parameters. It intertwines the method names with the arguments that it takes. Instead of `void doStuff(foo, bar, baz);`, its `- (void) doStuffFoo:(id) foo bar:(id) bar baz:(id) baz;` (which can also be written (and compiled) as: `- (void) :foo:bar:baz;` if you wanted).