Regarding Objective-C & Copland 2010
kickingbear.com
kickingbear.com
From early 2006 to late 2010 I worked for Apple.
Now, I'd have to say that I disagree. True, technology is a treadmill. What Apple has gotten really good at, though, is moving the treadmill forward instead of running just to stay in the same place.
Everyone knows that computers get cheaper, right? See a model you like; wait 6 months; and buy it for 20-50% less. Not with Apple, though. Instead Apple just keeps the price the same and moves the specs up.
Same, too, with the technology. While everyone else is out there writing hyper-super-parallel-concurrent-evented-message-passing-functional-object-oriented-metapseudotemplate code, Apple is writing code the same way today that they did in 2000...except this time it's running on the computer in your pocket instead of the tower on your desk.
I get it, though. We're engineers. We love design. So we buy Apple kit and we would love to believe that our preferred brand has the same values we do. It certainly did. This is, after all, the company that Woz founded, that employed Raskin and Kay, that still employes Bud Tribble...but I, personally, think that the "glory days" of Apple/NeXT's preeminence in core software are behind them. Of course, UI? UX? Hardware? That's where Apple's engineering focus lies now.
Copland 2010 was avoided not because Apple did something about it, but because they changed the rules completely.
That simple omission introduces a large amount of pain when working with Objective-C for a large class of applications - especially web-aware, but also including code that parses files.
It's the same story with regards to regular expressions - yes there are libraries that can do the job, but they just aren't as pleasant to use as regexps are in the various scripting languages - python, ruby, perl, javascript, etc, where regular expressions are first-class
NSString *myString = @"This is a" @" string.";
Adjacent string constants are concatenated by the preprocessor. Otherwise, I don't think it's too much hassle to call stringByAppendingString:. NSString *foo = @"Hello, " + userName + @"! (^_^)";Having worked with Cocoa, Ruby and PyQt, I would really really like to see that!
As others have said though, this is a somewhat unlikely future right now.
Siracusa himself concedes in his podcast that Obj-C has garbage collection, but that it was something of a second class citizen. Because garbage collection has been tacked on (and currently not supported on iOS) old pros are unlikely to adopt it. On top of that, newbies who look to the old pros for guidance are going to follow their lead and not use it either.
Siracusa also used the same argument against Obj-C's dot syntax.
It doesn't nest as well and you have to look at two different syntaxes to see one selector. I kinda wish they had done something like object.[selector:value selector2:value2]
It's been successfully achieved with Convention Over Configuration. See MacRuby's HotCocoa.
[[^ (Foo*) (Foo* bar) { return bar; } copy] autorelease]
is a pretty ugly way of writing a lambda. It's like arguing that java can pass functions via anonymous classes. Yes, technically you can but it's pretty ugly.Another underlying problem is that the only language that can call Obj-C libraries is Obj-C.
.NET and the JVM solved this problem long ago, I know that Python/Perl/Ruby also have this problem outside of the JVM/CLR.
As far as GC, Obj-C effectively doesn't have it as most Obj-C outside of Apple is written for iOS which doesn't support GC.
You could create a point system and call Obj-C a modern language but working with it feels anything but. Apple doesn't need any serious rewrite, they need to make MacRuby work on the iPhone. That's it.
[array transformFoos:^(Foo*) (Foo* bar) {
return bar;
}];
I'm not sure there is a more succinct way to write a lambda with typed arguments and a typed return value.A more real-world example employing blocks with GCD would be:
dispatch_queue_t queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
// do some time-consuming work
dispatch_async(dispatch_get_main_queue() ^{
// do stuff on the main thread, like updating UI
});
});
That's actually pure C. Typical block usage with Cocoa would be something like: [myArray enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// do something with obj concurrently
}];But I see it as a good alternative for apple development in a near future, let's just hope Apple sees it as well.
In practice this is the case, but the Etoile guys have written AppKit applications in Io and Smalltalk, and they have an ObjC -> JavaScript compiler running thanks to LLVM. So given time, I think this statement will come to be eroded away.
Lua is already on the iPhone, and will probably give you an order of magnitude performance advantage over Ruby.