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
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).
MacRuby iPhone development shall be considered for the near future
Please use the correct nuance.
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.
Delivering Performance Under Schedule and Resource Pressure: Lessons Learned at Google and Microsoft
Ivan Filho Mar 06, 2014
Andrew Stellman Mar 06, 2014