Over a million developers have joined DZone.

Programming iOS with JavaScript

· Mobile Zone

So while we’re all twiddling our thumbs waiting for The Great Dev Center Outage of 2013 to end so we can get back to work, how about we find some useful yet completely non-Apple technology to brush up on while we wait? Yes, yes, “useful” and “non-Apple” make it sound like we’re doing a humor piece today, but no! Here’s something you just might have overlooked that gives usefulness to what may be a new skill to brush up, brush off or just plain start on learning, and that is: JavaScript!

‘Course, we’ve had ways of communicating with UIWebView for forever, and there’s a veritable plethora of platforms for hybrid apps, but you may have missed a more deeply integrated method that we posted about a while back:

… 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…

… 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…

Looks like that bug got filed! In case you don’t follow WebKit commits, read Apple’s new Objective-C to Javascript Bridge:

A few month back, Apple quietly slipped a very nice Objective-C to Javascript bridge into WebKit. Since the first commit while we were busy celebrating New Year’s Eve, it has been fairly actively developed and improved. This new API supports straightforward embedding of the JavaScriptCore interpreter into native Objective-C projects, including reading and writing variables and object members with appropriate type coercion, calling methods on JavaScript objects, and directly binding Objective-C objects into JavaScript.

It seems likely that this API is going to become public in Mac OS X 10.9 (where JavaScriptCore is already a public framework), and it might be a hint of an eventual public API on iOS. Either way, a new option for building hybrid JavaScript apps is here…

And not too long later, why look what shows up in public:

JavaScript and iOS 7 – The bridge to happiness

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.”

And another:

iOS 7 Development: Everything You Need To Know To Get Started

JavaScriptCore – Allows for wrapping of standard JavaScript objects into Objective-C (the code used for iOS apps). Should allow for porting of apps between different mobile operating system platforms.

So, seems like a good idea to brush up on JavaScript, yes…

javascript_good_and_bad_parts.jpg

… but let’s try to be selective about it, shall we? So, Dear Readers; what’s your best resources for getting up to speed quickly while we keep refreshing the dev portal every few minutes? Got a couple here,

Topics:

Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}