Under the Bridge

JavaScript Impact

Yeah, yeah, another post about Titanium or PhoneGap or something, you’re thinking? Well, not exactly:

iOS and JavaScript – for Real this Time!

Less talk, more action – Apple just approved two of my JavaScript games for the AppStore: Biolab Disaster and Drop. Both are free; go check them out. You can also play them in your browser here and here.

Both games are pretty simple (the source for Drop is only 300 odd lines long) and written with my JavaScript Game Engine Impact

So what’s so special about these two games now? They don’t use PhoneGap or Titanium. They don’t even use a UIWebView. Instead, they bypass the iPhone’s browser altogether and use Apple’s JavaScript interpreter (JavaScriptCore) directly…

… you might remember a post from October 2010 where I attempted the exact same thing. Back then I used the JavaScriptCore library that is already available on iOS and used by Apple in Mobile Safari. The problem was, that this library is “private”, meaning that Apple does not want you to use it. And since you can’t publish anything in the AppStore that uses private libraries I abandoned the idea.

However I recently revisited the project, because there was still a chance to make this work: JavaScriptCore is a part of the open source WebKit project. Instead of using the private library that comes with iOS, you theoretically could compile your own version of this library and bundle it together with your App. Which is exactly what I did…

Well, that’s certainly an intriguing approach yes. We recall a session we were at one WWDC a few years back — 2007, maybe? — which talked about doing exactly this on desktop OS X, where JavaScriptCore is public, but that seems to have pretty much fallen off the radar since. But speaking of Radar, if you like the idea of being able to use JavaScriptCore directly instead of the various cross-platform frameworks out there, as Gus Mueller suggests here:

Even better would be if Apple would make JavaScriptCore public, and even turn on the Nitro JIT for everyone. I suppose I should file a bug on that.

Remember, even though to all appearances yes it looks like your bug filing time is utterly wasted, they seriously do use it to help setting priorities inside Apple. So make your vote heard!

h/t: readwritehack!