Your opinion matters! Please fill in the InfoQ Survey!

Mac and Ruby Roundup: MacRuby AOT, DMGs with ChocTop

| by Werner Schuster Follow 4 Followers on Jul 18, 2009. Estimated reading time: 1 minute |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

MacRuby's tight integration with the Cocoa platform is one of its big assets, comparable to JRuby's or IronRuby's integration with their underlying platforms. MacRuby seems to be the best way for Mac developers to use Ruby for client applications. Recent work on the experimental branch has been improving the Ahead of Time (AOT) compilation:

Introducing macrubyc, a command line tool interface to the AOT compiler.
macrubyc allows you to compile a given Ruby file into a Mach-O object file and/or produce a final executable.

While it's definitely possible to write and deploy Ruby applications written with MacRuby today, these apps still need to be shipped with the MacRuby runtime. The aim for the AOT implementation is to solve this:

Produced Mach-O objects are true object files. They can be used to form a MacRuby executable or you can also use them into your Objective-C project that uses the MacRuby Objective-C API.

Produced executables embed all the compiled Ruby code as well as MacRuby, statically. It can be distributed as is and does not depend on anything MacRuby or LLVM at runtime. The Ruby source code is compiled into native machine code (same process as we do at runtime with the JIT compiler), so it's also a good way to obfuscate the source code. The final binary looks like an Objective-C binary (except that it's larger).

One example of a utility written with MacRuby is Chris Wanstrath's BaconDrop tool, which is written using MacRuby. While the tool is tiny, it weighs in at around 15 MB due to the bundled MacRuby - an AOT compiled binary should be slimmer.

BaconDrop is also an example of how Ruby-powered tools can help with Mac development. Bacondrop comes in the form of a Mac DMG file - created with a utility called ChocTop, developed by Dr Nic. The tool works for all Cocoa applications, and automates the tedious bit of DMG creation complete with Sparkle setup (Sparkle handles software updates). ChocTop has a DSL-ish configuration system and adds a few task to your rake file.

Once it's possible to AOT compile all MacRuby applications, Ruby seems to be a viable competitor to Objective-C for OS X application development (probably not iPhone development as the iPhone's Objective-C runtime doesn't support Garbage Collection).

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

MacRuby iPhone development shall be considered for the near future by Roberto Nogueira

Nice post, but I think MacRuby iPhone development shall be considered in the near future as nowadays it is being the most profitable and attractive marked for software developers. As Ruby being one of the most productive languages this would be a dream for SDK development!!

Please use the correct nuance. by Eloy Duran

“MacRuby seems to be the best way for Mac developers to use Ruby for client applications.” Nope, RubyCocoa is still _the best way_ for Mac developers to use Ruby for client applications. Trying to write a bigger app will show that easily.

While we are working hard to make MacRuby the RubyCocoa replacement, it's not there yet. We definitely need people to use it to get it there, but saying these things will simply make people disappointed at some point and isn't really helping them right now. Apps can be ported easily from RubyCocoa to MacRuby later on.

Please consider this comment to be meant as being helpful and not as a flame.

A RubyCocoa & MacRuby committer.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you