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+ globalsenior 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,...)?
This content is in the Scripting topic
Related Topics:
-
Related Editorial
-
Related Sponsors
-
Popular across InfoQ
-
Microsoft Patches Critical ASP.NET Core Vulnerability with 9.9 Severity Score
-
Monzo’s Real-Time Fraud Detection Architecture with BigQuery and Microservices
-
Architecture Should Model the World as it Really is: a Conversation with Randy Shoup
-
OpenJDK News Roundup: Vector API, Ahead-of-Time Object Caching, Prepare to Make Final Mean Final
-
Reducing False Positives in Retrieval-Augmented Generation (RAG) Semantic Caching: a Banking Case Study
-
Anthropic Adds Sandboxing and Web Access to Claude Code for Safer AI-Powered Coding
-
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