JavaScript and iOS 7

The bridge to happiness

Dion Almaer

--

Everyone is talking about the flatness, but I love to look around and see some of the smaller wins on the developer side of an iOS SDK.

I am really excited about something that I haven’t seen mentioned much, and that is a new bridge between the worlds of JavaScript and the runtime of iOS and OS X:

Introducing a new Objective-C API to JavaScriptCore. iOS developers can now integrate scripting into their apps without having to bundle custom language interpreters. This API builds on top of the existing C API to JavaScriptCore available on Mac, and makes programming with JavaScript much easier and less error-prone.

As mentioned, the desktop world had this bridge, and there are various ways to embed a JavaScript interpreter and the like, but getting this first class support is exciting.

The API is pretty clean, so the JavaScript code that calls into Objective-C looks sane OtherThanSoVeryVeryVerbose, and vice versa.

If you have areas of your application where “scripting” would fit in, then this could be a fantastic solution. Areas such as gaming have already done this for a long time. Even though the “apple rules” talk about not being able to download code and run it, games have been doing just that for ages (in Lua, or other languages). Anecdotally Apple seems to not care any more (don’t quote me on that / your mileage may vary).

Beyond games though, I see a lot of use cases where I would love to A/B test areas of the app, and JavaScript could “drive” those tests quite nicely indeed.

I haven’t been able to go deep and see what limitations exist, but man, I am excited to see what can be done.

--

--