InfoQ Homepage News Mac and Ruby Roundup: MacRuby AOT, DMGs with ChocTop

Mac and Ruby Roundup: MacRuby AOT, DMGs with ChocTop


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).

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article


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.

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

Community comments

  • MacRuby iPhone development shall be considered for the near future

    by Roberto Nogueira,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    “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

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


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.