News for hackers. Stuff that matters.
Re:Non-Apple's Mistake by orangecat on Friday April 16, 2010 @05:35PM (#1271996)
You should try building an iPhone app and see how it compares.

I have, and Android wins for me. Cocoa Touch is a decent API (in most cases; what's with NSImage vs CGImage vs CIImage?), but Objective-C is seriously outdated. It usually needs more boilerplate than even Java, and manual memory management, lack of namespaces, and header files are silly in 2010.

Re:Non-Apple's Mistake by swannodette on Friday April 16, 2010 @07:04PM (#1272208)
> more boilerplate than Java

whatever. Objective-C is far closer to the elegant dynamism of SmallTalk than Java.

> manual memory management

Makes sense. This is a resource constrained device.

> lack of namespaces

This is a phone not an enterprise server.

> header files

On a device with an underpowered processor the focus on C-based languaged has been paying back serious dividends as far as the responsiveness of the platform's applications.

Re:Non-Apple's Mistake by KirinDave on Friday April 16, 2010 @05:43PM (#1272022)
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.

Re:Non-Apple's Mistake by irons on Friday April 16, 2010 @08:31PM (#1272333)
To 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.

Re:Non-Apple's Mistake by KirinDave on Friday April 16, 2010 @09:08PM (#1272380)
I 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.
Re:Non-Apple's Mistake by irons on Saturday April 17, 2010 @02:54PM (#1273502)
With 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.
Re:Non-Apple's Mistake by KirinDave on Friday April 23, 2010 @11:11AM (#1288255)
There are collectors that work very well in space constrained, processor constrained environments. It's not impossible.
Re:Non-Apple's Mistake by cpr on Friday April 16, 2010 @07:23PM (#1272242)
Yes, looks like Obj-C blocks made it to 4.0.

GC is probably a ways off for obvious reasons.

Re:Non-Apple's Mistake by elai on Friday April 16, 2010 @07:11PM (#1272226)
Yes, 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.
Re:Non-Apple's Mistake by glhaynes on Friday April 16, 2010 @11:51PM (#1272581)
Over the life of the code, I'm only gonna type it once; I may read it a hundred times.
Re:Non-Apple's Mistake by elai on Tuesday April 20, 2010 @02:31PM (#1280200)
To 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.
Re:Non-Apple's Mistake by cpr on Tuesday April 20, 2010 @10:05PM (#1281197)
Except 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.

Re:Non-Apple's Mistake by crux_ on Friday April 16, 2010 @05:49PM (#1272038)
Isn't one of the big problems here that "rule-based syntax translators" are kind of disallowed?
Re:Non-Apple's Mistake by KirinDave on Friday April 16, 2010 @09:10PM (#1272384)
Not if they produce straightforward objective c. How would one even separate such code generation from the use of regular #define?
Re:Non-Apple's Mistake by daeken on Friday April 16, 2010 @11:14PM (#1272544)
You'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.
Re:Non-Apple's Mistake by KirinDave on Saturday April 17, 2010 @12:07PM (#1273220)
I'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.

Re:Non-Apple's Mistake by umjames on Friday April 16, 2010 @07:15PM (#1272233)
Assuming we're only talking about the iPhone APIs, then there's no NSImage or CIImage (Mac OS X desktop only).

As for UIImage and CGImageRef, which are on the iPhone, UIImage is an Objective-C class, whereas CGImageRef is a C opaque struct.

CGImageRef comes from the CoreGraphics (aka Quartz) lower-level 2D drawing APIs (implemented using C functions). This framework was around before the iPhone as it is also found in the Mac OS X APIs. UIImage gives you the ability to use a CGImageRef as an object. It doesn't expose all of the functionality found at the CoreGraphics layer, but it can be easier to use with other ObjC classes.

Re:Non-Apple's Mistake by orangecat on Friday April 16, 2010 @09:40PM (#1272427)
You're right, I was thinking of desktop Mac OS X there, and an especially annoying section of code where I was trying to get those three image APIs to talk to each other. Apple did in fact remove a lot of cruft and duplication in the iPhone API, and that's good. Still, there are a number of cases like that where you have to switch between ObjC method calls and straight C functions. Not a huge deal, but it's clearly not the SmallTalk-style pure OO.