4 ms·
Well, sort of. I wouldn't really call it running "ruby code on the Objective-C runtime". Your Ruby code is effectively being converted to Cocoa API calls during
by objclxt 14y ago
Well, sort of. I wouldn't really call it running "ruby code on the Objective-C runtime". Your Ruby code is effectively being converted to Cocoa API calls during the compilation process. RubyMotion has a number of Objective-C subclasses that match back to Ruby objects (for example, strings in RubyMotion aren't NSStrings, but a subclass of them). If you dump the headers out of a RubyMotion app you can pretty clearly see this.
Ruby and Objective-C definitely aren't that similar internally - as someone else has suggested, there's no technical reason you couldn't do something similar for Python. It just happens that Ruby to Cocoa bindings have been around for a while (for some time with Apple support), and as a result there has been generally more interest in carrying it forward.
I've probably failed to adequately explain how it works, but the MacRuby source is available on GitHub, and Laurent Sansonetti has done a run through how RubyMotion does it's thing here: http://rubysource.com/laurent-sansonetti-on-rubymotion-internals/ http://rubysource.com/laurent-sansonetti-on-rubymotion-inter...
- flixic 14y agoThanks! I knew most of this, but for some reason had an impression that ruby was in particularly nice spot to subclass Obj-C classes. I have to agree, you are right, and other languages could follow RubyMotion's model.