JSCocoa : easily call Objective-C from javascript

Posted: October 9, 2008 in IT/Dev
Tags:

Following Cappuccino, a new open-source project (developed by a french man) promoting Cocoa has been launched, JSCocoa. This javascript library uses JavascriptCore (the javascript engine from Apple’s WebKit framework) in order to call C and/or Objective-C code from javascript.

Contrary to Cappuccino (that is a full rewrite of Cocoa classes in javascript, plus a dynamic compiler to convert at runtime Objective-J client code to standard javascript), JSCocoa provides a pure javascript syntax (that is less close to Objective-C than Objective-J). However JSCocoa brings some easy notations derived from Rubby and jQuery in order to simplify the syntax.

Finally, the end code executed is Objective-C (contrary to the Cappuccino solution), through ObjCRuntimeBridgeSupport and libffi. Then JSCocoa only works on MacOSX (10.5.5, PPC and Intel), what greatly reduces its interest. It would be better if Apple decided to release the ObjCRuntime on Windows, but it would sill require a porting of Cocoa classes (that is the YellowBox…) And then the bridge would be less useful (still the case on OSX, in fact it makes deployment of applications easier – only a browser needed – and paves the way for accessibility features, that is access to system fonctionnalities, an area where Cappuccino will have to use a similar bridge).

As it is only a bridge, the install only weights 1,3Mb (includes an example, JSCoreAnimation). The solution also allows to load NIBs from javascript client code, but IBOutlet and IBAction instance variables have to be defined manually in the code.

Then JSCocoa is simply an easier way to use the bridge presented some months ago, that is calling d’Objective-C from a WebView (Webkit view), through a WebScriptObject.
It is the third solution popularizing Cocoa in a few months, without counting the iPhone UIKit.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s