[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Embedding MacRuby For Application Scripting

Embedding MacRuby For Application Scripting

This item in japanese

Oct 14, 2008 1 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

The upcoming MacRuby release will contain new features to facilitate embedding and using the runtime to script Objective-C applications. Matt Mower explains the reasons for choosing MacRuby over other Objective-C scripting options, as well as a few APIs currently available in the MacRuby trunk. The application Matt uses MacRuby for is Elysium, an application for generative music.

Something I've had in mind, almost from the beginning, was that Elysium should be scriptable. That, through the ability to script parts of the application, you can have more control over the musical strategy. For example a script might regulate how often new playheads are generated in order to control the "energy" of a piece.


Matt continues to explains how to use MacRuby from an Objective-C application and shows a few of the calls to use. For instance, to e xecute some Ruby source from a Cocoa application:

[[MacRuby sharedRuntime] evaluateString:rubySource]

Matt's examples also show an easy to way use snippets of Ruby code as callbacks for the Objective-C application.

To see the changes, which should make it into MacRuby 0.4, there's now a GitHub mirror of MacRuby (the Commits page for the repository).

MacRuby is tightly integrated with Objective-C, eg. many basic Ruby types are mapped directly to Objective-C types. With this, MacRuby has similar benefits as JRuby and IronRuby, ie. simple and efficient access to a large amount of existing libraries, such as the ones exposed by OS X. Apple, for instance, already uses Ruby (not MacRuby, though) as implementation language for the iPhone Enterprise utility.

Are you working on an Objective-C application? If yes, would you choose MacRuby or any of the other scripting options Matt Mower lists (Nu, JSCore,...)?

Rate this Article

Adoption
Style

This content is in the Scripting topic

Related Topics:

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /