News for hackers. Stuff that matters.
Re:Apple's new Objective-C to Javascript Bridge by apike on Wednesday May 15, 2013 @12:31PM (#5713083)
My guess is that this would be fast enough to build almost any Mac app and many iOS apps. The bigger question for me is, how gross would it be to deal with the "Objective-C-ness" of the Cocoa APIs through JavaScript?
Re:Apple's new Objective-C to Javascript Bridge by nglevin on Wednesday May 15, 2013 @12:58PM (#5713263)
Functionally, this appears to be identical to JavaScriptCore's longstanding C bridge [1]. If Objective-C isn't your preference, there's nothing stopping you from calling into the C bridge from C++ or just plain C.

On iOS, developers have had to compile their own version of JavaScriptCore to use this API. That's the basis for HTML5 game engines like Impact [2], and some HTML5-to-Objective-C middleware platforms.

Unfortunately, until Apple says otherwise, this version of JSC is still subject to Apple's App Store review guidelines [3]. Thanks to guideline 2.8, you can't have your app, running JSC, execute any JavaScript that doesn't ship within the bundle of your app.

I'd like to see that rule change, someday. Exposing this Objective-C API in a future iOS release isn't going to change the status quo.

[1] - http://developer.apple.com/library/mac/#documentation/Carbon...

[2] - http://impactjs.com

[3] - https://developer.apple.com/appstore/guidelines.html

Re:Apple's new Objective-C to Javascript Bridge by apike on Wednesday May 15, 2013 @01:05PM (#5713310)
All good points. The big difference with the bridge going to Objective-C, though, is that I believe it is now possible to build a native UI by calling right from JavaScript to Objective-C. Impact is interesting for games and canvas-like rendering, but what I'd love is to be able to build the models and controllers of a highly performant, native-UI iOS app using JavaScript and UIKit. Sort of like Appcelerator with a layer removed.
Re:Apple's new Objective-C to Javascript Bridge by nglevin on Wednesday May 15, 2013 @01:10PM (#5713349)
That's fair. This does save one ugly, extra step that I didn't mention, which would be to call into the Objective-C runtime's C API [1] to dispatch messages and introspect Objective-C classes.

Should make it easier for developers to build their own middleware platform without getting too deep into reams of C boilerplate.

[1] - https://developer.apple.com/library/ios/#documentation/Cocoa...

Re:Apple's new Objective-C to Javascript Bridge by pi18n on Wednesday May 15, 2013 @10:01PM (#5716451)
You should be able to to run code downloaded as part of IAP also. But this is one of the major things I wish they would change, and also one of the major reasons I'll be switching to Android.
Re:Apple's new Objective-C to Javascript Bridge by nglevin on Wednesday May 15, 2013 @10:13PM (#5716501)
Which is what I meant by "within the bundle of your app." That may have been a bit too iOS developer-centric, I apologize.

In Foundation, [NSBundle mainBundle] returns a reference to an object representing your application's root directory, and the code and resources found within. Roughly the same bits that you'd find within an unpacked IAP file.

Re:Apple's new Objective-C to Javascript Bridge by Millennium on Wednesday May 15, 2013 @12:48PM (#5713192)
That depends on the state of the bridge. Previous language bridges by Apple have generally bridged the gaps pretty well, with the main "Objective-C" relic being really, really long method names.

That said, all of the bridges I've seen were to classical-OO languages. It is possible that Cocoa won't translate as well to prototypal-OO languages like JavaScript. It will be interesting to see how Apple navigates that paradigm shift.

Re:Apple's new Objective-C to Javascript Bridge by wwweston on Wednesday May 15, 2013 @02:40PM (#5713901)
> all of the bridges I've seen were to classical-OO languages. It is possible that Cocoa won't translate as well to prototypal-OO languages like JavaScript.

This has already been done with Mozilla's Rhino (JavaScript or Java) and it turns out the be pretty easy to work with Java classes in that context.

Re:Apple's new Objective-C to Javascript Bridge by dottrap on Wednesday May 15, 2013 @04:16PM (#5714565)
JSCocoa has been there, done that. They even have optional Objective-J support.
Re:Apple's new Objective-C to Javascript Bridge by gsnedders on Wednesday May 15, 2013 @02:01PM (#5713662)
On iOS it won't be that quick: you don't get anything more than the JS interpreter, as you cannot allocate any executable memory on iOS, so any JITing compiler is out of the question.
Re:Apple's new Objective-C to Javascript Bridge by udp on Wednesday May 15, 2013 @03:00PM (#5714013)
Wouldn't this be exempt from that limitation, with the JavaScript engine being distributed as part of iOS itself?
Re:Apple's new Objective-C to Javascript Bridge by gsnedders on Wednesday May 15, 2013 @06:06PM (#5715313)
No, it applies per process: whether or not it came from a dynamically linked library distributed as part of the system is irrelevant. This is why UIWebView is slower outside of Safari.
Re:Apple's new Objective-C to Javascript Bridge by pi18n on Wednesday May 15, 2013 @10:03PM (#5716458)
They might be moving towards some kind of XPC service so you can talk to a JIT through a Mach port.

Speculation is my own, derived from: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-...

Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @03:11PM (#5714084)
It's important to remember that Apple shipped both the Ruby and Python Objective-C bridges in ~10.5 era OS X. You can (and I have) written OS X native software in Python; it wasn't super pretty, but the concepts mapped across reasonably well.

So I wouldn't take this as necessarily the sign of a shift in anything.

Re:Apple's new Objective-C to Javascript Bridge by dottrap on Wednesday May 15, 2013 @03:42PM (#5714310)
Also, people at Apple like Objective-C and its Smalltalk influences. For those of us who've been in the NeXT/Apple ecosystem a long time, it's clear that employees at Apple see Ruby as more interesting than say Javascript because of the Smalltalk influences. If any shift were to occur, money is on Ruby. But Apple likes Objective-C and no shift seems likely and we also saw what happened with MacRuby and the author leaving to do RubyMotion.
Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @03:45PM (#5714330)
And they've invested a lot in the tooling and environment. It's not like they're just running a stock gcc toolchain; they've put a lot of very smart people on very hard problems in the language space.
Re:Apple's new Objective-C to Javascript Bridge by dottrap on Wednesday May 15, 2013 @03:59PM (#5714458)
Agreed. And another problem is that all these interpreted languages are terrible at exploiting parallelism which is a problem as we get more processor cores.

They were able to solve this in C by inventing Blocks and GCD.

Re:Apple's new Objective-C to Javascript Bridge by Moto7451 on Wednesday May 15, 2013 @05:10PM (#5714940)
They used to have a Java bridge as well[1]. WebObjects moved from Objective C to Java at some point in the early '00s.

[1]http://cocoadevcentral.com/articles/000024.php