3 ms·
Well ObjC straddles a very interesting place. It's as low-level as C++ but has high level message passing method dispatch as well. If it seems a little crufty,
by KirinDave 17y ago
Well ObjC straddles a very interesting place. It's as low-level as C++ but has high level message passing method dispatch as well. If it seems a little crufty, it's because it's living in a very peculiar place trying to serve a variety of masters.
Hopefully 4.0 will start to pave the way for the ObjC2.0 stuff to come to iPhone. They are really big improvements to the language.
Also, rule-based syntax translators could give you a ton of stuff as a preprocessing pass to your code. Write something for NSArray literals and you'll be a hero.
- crux_ 17y agoIsn't one of the big problems here that "rule-based syntax translators" are kind of disallowed?
- KirinDave 17y agoNot if they produce straightforward objective c. How would one even separate such code generation from the use of regular #define?
- daeken 17y agoYou're right, they couldn't tell. But that doesn't mean they're not disallowed -- unless you're writing C, C++, Obj-C, or Javascript, it's disallowed, period. But that doesn't mean people won't do it.
- KirinDave 17y agoI'm not sure I agree that code translation is entirely disallowed. Part of the problem, though, is that the legalese in the iphone 4 revision is maddeningly obscure and unhelpful. We're not even sure if embedded Lua interpreters are really banned. I'm sure Apple is considering that very question.
- elai 17y agoYes, something to replace the super crufty NSArray / NSMutableArray / NSSet / NSDictionary, syntax would be really good. Small talk message passing was meant to have short, small one symbol binary operators, but unfortunately that elegance is not there in objective c.
- glhaynes 17y agoOver the life of the code, I'm only gonna type it once; I may read it a hundred times.
- elai 17y agoTo be honest with you [[stuff objectAtIndex:5] objectForKey:@"name"] is less readable than stuff[5][@"name"]. And you type this kind of code constantly over and over again, it can really stack up and create something that would be simple to read in other languages.
- cpr 17y agoExcept that if you're used to Smalltalk, this is just standard fare. I agree that a Python-like shorthand would be great at the object level, but then you'd have a mixture of shorthand and longhand, and that would be ugly.
- cpr 17y agoYes, looks like Obj-C blocks made it to 4.0. GC is probably a ways off for obvious reasons.
- irons 17y agoTo be pedantic, "Objective-C 2.0" features are things the iPhone always had, like properties and fast enumeration, and/or had first, like the modern runtime (which solves the fragile base class problem, and which Mac apps still only get if they're 64-bit). Blocks were a Snow Leopard feature, implemented as a C extension, and sprinkled throughout Apple's APIs; no direct relationship to Obj-C.
- KirinDave 17y agoI was thinking more along the lines of the garbage collector. That's sort of the "tent pole" feature of the last cycle of objc revisions.
- irons 17y agoWith the first iPad model still at 256 MB RAM, and no sign of GC in the iPhone OS 4 preview, memory management will be with the platform for a long time. I think we'll see multi-core first.
- KirinDave 17y agoThere are collectors that work very well in space constrained, processor constrained environments. It's not impossible.