ANN: NodObjC - The Objective-C interpreter for NodeJS

717 views
Skip to first unread message

Nathan Rajlich

unread,
Jul 11, 2011, 2:35:48 AM7/11/11
to nod...@googlegroups.com
Hey all,

I just wanted to give a quick shout-out about my latest hackery with node: an Objective-C interpreter running through Node! This is some crazy stuff offering some crazy possibilites, include writing OSX or iOS native apps entirely with node and Javascript! Now, note that this idea is still very new, I just started on it this weekend, and you can't currently do these cool things. But it's coming!

I'm building a high-level framework I'm calling `NodObjC`[0], which offers an easy-to-use API directly generated from the APIs defined in the Frameworks themselves. Here's the example from the README:

var $ = require('NodObjC');

// First you need to "load" the Framework
var Foundation = $.import('Foundation');

// Make the 'NSMutableArray' constructor be global
var NSMutableArray = Foundation.NSMutableArray;

// Now let's create an NSMutableArray
var array = NSMutableArray.alloc().initWithCapacity_(3);

// Add some JS objects to the array
array.addObject_("Hello World!");
array.addObject_({ an: 'object' });
array.addObject_(NSMutableArray);

// Print out the contents (calling [array describe])
console.log(array);
Additionally, the low-level module that exposes the guts of the Objective-C Runtime which I'm calling `node-objc`[1] is also available. I would not recommend using this API directly, but it's what `NodObjC` uses to do it's magic.

Both are still very incomplete, but I have big visions and really just wanted to spark some community interest. So please, let me know what you think and it'll motivate me to keep going!!

Louis-Philippe

unread,
Jul 11, 2011, 9:31:43 AM7/11/11
to nod...@googlegroups.com
Is this to build Node/Javascript web apps?
I get confused when you invoke the Objective-C Runtime...

regards,

L-P

Nathan Rajlich

unread,
Jul 11, 2011, 2:20:11 PM7/11/11
to nod...@googlegroups.com
I was thinking more for the ability to interact with the OSX APIs and build native GUI apps using just node and JavaScript.

That being said you definitely could use the OSX APIs in a node server you've written, and expose some functionality to your web app through there. For example, I'm planning on rewriting nTunes (when this is stable enough) to use the exposed Objective-C API directly, rather than firing up child processes for every request. I'm sure there's many more ObjC apis that could be useful when intertwined with node.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Zhami

unread,
Jul 12, 2011, 7:46:55 AM7/12/11
to nodejs
+1

I can see this as useful for building a native app that needs to pull
in a lot of Web-based content (HTML and JSON). I built a Twitter app
a while back, and it sure would have been easier to pull feeds and
parse results with Javascript and node modules. I've also done some
"screen scraping" and having jsdom is really useful for this. The
examples go on and on...

btw: I haven't tried yet, but assume that beside Foundation you can
get to Cocoa and other frameworks.

also: Nathan, have you tried this from inside IB?

Akzhan Abdulin

unread,
Sep 5, 2011, 10:55:07 AM9/5/11
to nod...@googlegroups.com
Hello Nathan,

Is it possible to create Objective-C class descendants (controllers, for example)?

2011/7/11 Nathan Rajlich <nat...@tootallnate.net>
--

Nathan Rajlich

unread,
Sep 5, 2011, 1:42:27 PM9/5/11
to nod...@googlegroups.com
Akzhan,

If you mean "is it possible to create subclasses of an existing class?", then the answer is YES! Take a look this this "extend.js" example in the repo:



And for everyone else out there, be sure and check out NodObjC if you're on a Mac, cause it's some fun stuff! Just messing around in the REPL creating Objective-C objects and calling methods on them is highly enjoyable IMO.

I'm rather excited about this module lately because just last night I got the first basic "hello world" Cocoa GUI app running, in pure JavaScript! Here's what the code and a screenshot looks like: https://gist.github.com/1194032. So needless to say, some awesome capabilities are beginning to open up with this bridge!

Also head over to the Freenode IRC channel #nodobjc to chat about writing Cocoa apps with Node!

Matt

unread,
Sep 5, 2011, 6:29:53 PM9/5/11
to nod...@googlegroups.com
That's awesome. Does it use the bridge XML files to give you access to the entire API?

Nick

unread,
Sep 5, 2011, 9:02:29 PM9/5/11
to nodejs
I don't know if I'll ever use it, but this is beyond cool.

Nathan Rajlich

unread,
Sep 6, 2011, 2:26:37 AM9/6/11
to nod...@googlegroups.com
Matt,

Yes, the BridgeSupport files are used to provide access to the C APIs, and the Obj-C runtime functions allow us to introspect all the the information about Objective-C Classes that we need. The result: NodObjC!
Reply all
Reply to author
Forward
0 new messages