MacRuby + Mac App Store == Low Hanging Fruit for Rubyists »
Created at: 21.10.2010 14:05, source: Ruby Inside, tagged: Controversy OS X Specific
At its "Back To Mac" presentation yesterday, Apple unveiled the Mac App Store, an equivalent of the iOS App Store for the Mac. Given the relentless development and improvement of MacRuby and the power it brings Rubyists in developing complete OS X applications, I'm convinced that the time is right for Ruby to make a big splash on the OS X GUI app development front.
When I mentioned the above observation on Twitter, Geoffrey Grosenbach of PeepCode pointed out:

He's right, but things like app stores have a funny way of acting as catalysts for developers to come out of the woodwork and try new things out. Even taking the "evils" of app stores into account (and Apple's performed more than its fair share of evil incantations on iPhone developers), the ease with which you can put apps for sale and take money from customers (if only a 70% share) is appealing. The iPhone App Store almost reinvented casual gaming, for instance, and people I'd never have considered to try and develop a mobile app have been lured into the iPhone fold.
Given all of this, I think that if you want to develop OS X apps without moving away from Ruby, and you want to make proper money for your apps without setting up a Web site, building up traffic, and what not, now's the perfect time to look into MacRuby and Apple's Mac Developer Program. (But if you want to work on open source or sell your own stuff, do that too!)
Will Apple even allow Ruby built apps on to the App Store?
Keeping in mind the now semi-resolved 3.3.1 imbroglio, it's worth maintaining some healthy disdain as to Apple's intentions and future actions until they say something officially.
Someone's leaked the Mac Developer Program terms on to a pastebin site already, and nothing stands out to me as blocking the use of MacRuby for building App Store-deployed apps. Point 2.14 notes that apps must be packaged and submitted with Apple's own packaging tools included in Xcode, but since MacRuby is being developed at Apple, one hopes this will be easily done. Apple even has a guide called Developing Cocoa Applications Using MacRuby that digs into using Xcode.
Other points note that you can't install kexts (kernel extensions), have your own licensing system, offer "trials", download other apps from within your own, or use setuid/root privileges, but these affect the behavior of your program rather than its underlying formation.
John E Vincent suggests that point 2.24 "Apps that use deprecated or optionally installed technologies (e.g., Java, Rosetta) will be rejected" would reject the use of MacRuby. I disagree. In OS X, Java is a giant collection of frameworks maintained and updated by Apple as part of the OS, whereas you can build fully packaged, standalone OS X .app files with the MacRuby framework tightly packaged inside. I could be wrong, though - what say you?
Where next?
First, you're going to need to test the waters of building OS X GUI-based apps with MacRuby so head to the official site to download and install it. Be aware that you need to be running OS X 10.6 (Snow Leopard) or higher.
Next, read up on how to build a basic app. Choice reads include:
- Apple's Developing Cocoa Applications Using MacRuby guide is a reasonable place to start.
- A more significant and up to date resource is the currently-in-beta MacRuby: The Definitive Guide by Matt Aimonetti.
- Phusion's Creating our very first Mac application with Ruby is a great (and recent) step-by-step walkthrough.
Not a fan of reading? Alex Vollmer and Geoffrey Grosenbach have put together a Meet MacRuby screencast. It costs $12, but you're going to be raking in the millions with your new Mac app on the App Store, right?
Finally, once you're happy with the idea of developing Mac software in Ruby, you'll need to become a member of the Mac Developer Program. This is not the same as the iOS Developer Program and you'll need to pay another $99 per year fee to get into it. What do you get? Private discussion forums, technical support, pre-release software (including OS X builds), and the ability to sign and submit Mac apps to Apple for inclusion in the Mac App Store.
Disclaimer: If Apple comes out and says you have to use Objective C for your Mac App Store apps, don't blame me!
more »
Visually Inspect Ruby Object Models with DrX »
Created at: 29.04.2010 01:35, source: Ruby Inside, tagged: Linux Specific OS X Specific Tools
When you want to inspect your objects in Ruby, Object#inspect, p, or awesome_print are all valuable. You're stuck with plain-text, though, and primarily designed to look at object data rather than object models. If you want to drill down into parent classes, see object and class relationships, etc, then, check out DrX, a visual object inspector for Ruby!
DrX bills itself as a "small object inspector", but its key features are that it shows results visually (in a GUI interface) and that it focuses on showing the object model behind your objects, rather than the data contained within. A visual example of a DrX session should give you the idea:

Usage
Once DrX is installed (more on that in the next section), you just require 'drx' it into your app (or even within irb) and then use the Object#see method to get DrX into action:
require 'drx' 123.see
Even this rudimentary example will bring up an interesting graph. The DrX author does, however, provide a more interesting example to show off DrX's introspective features:
s = "wizard of oz" def s.strong "<strong>" + self + "!</strong>" end s.see
Installation and Prerequisites
Depending on your setup, DrX might take some serious work to get going. If you're running Linux and are heavy on your development experimentation, you might have everything ready to go. Just try gem install drx and see if the above examples work in irb.
Failing that, DrX uses Tk for its GUI work in order to be cross-platform and also requires GraphViz to be present. Install these with your package manager of choice and ensure that your Ruby installation has the Tk bindings installed (again, easier said than done).
On OS X 10.6 (Snow Leopard) I discovered that the stock Ruby installation does not include the Tk bindings, even though Tk is present otherwise. Rather than mess it up, I relied on the always-wonderful RVM and installed Ruby 1.9.2-preview1 (rvm install ruby-1.9.2-preview1). With this, Tk worked "out of the box" and gem install rbx was OK. For the Graphviz dependency, sudo port install graphviz did the trick and also "just worked." If you're one of the anti-Macports crowd, though, you might need to find a different approach.
more »
How To Build A Mac OS X App With XCode and MacRuby »
Created at: 15.03.2010 16:30, source: Ruby Inside, tagged: Cool OS X Specific
Want to develop a Mac OS X app without getting waist deep in Objective C? MacRuby is the answer, and it’s now mature enough to use directly from XCode to build fully-featured Ruby-powered Mac apps. “Jean Pierre Hernandez” of Phusion presents a walkthrough of how to do it, step by step.
The tutorial walks through:
- Creating a new project in XCode
- Designing an interface with Interface Builder
- Customizing form widgets
- Writing a controller in MacRuby
- Connecting the controller to the window
Any knowledge of XCode, Objective C, and Interface Builder will enable you to get through this walkthough a lot quicker, but it’s not essential.
Installing MacRuby and XCode
While it’s possible to install MacRuby by compiling yourself, it takes forever, so Jean Pierre recommends grabbing the latest stable binary release and going from there. It’s quick to install and doesn’t require any messing around at the command line. Also, if you haven’t yet installed XCode from your OS X discs, now’s the time – you’ll need XCode to get anywhere with this walkthrough. You can also download them from Apple.
Aside: Phusion Gets A New Homepage
As an aside, Phusion recently launched their all new official Web site. The grungey look and graffiti logo are gone, and have been replaced by shiny, modern 2010 gloss. They’re focusing on providing Ruby and Rails performance and underlying infrastructure services to companies who demand serious power from Ruby. Check it out.
more »
MacRuby 0.5 Released: A Significant, Stable Release »
Created at: 02.02.2010 02:23, source: Ruby Inside, tagged: News OS X Specific
MacRuby has hit a significant milestone in its development today: version 0.5! The key features include improved HotCocoa support (though this is now maintained separately from core on GitHub), better Ahead-Of-Time (AOT) compilation, and support for OS X 10.6's Grand Central Dispatch.
Give It A Go!
If you've got a Mac and haven't yet tried out MacRuby, give it a go - its speed and general level of support for Ruby is very impressive. You can download MacRuby as a standalone package with installer (for OS X 10.6 and higher) or if you're using RVM, do an update and then rvm install macruby to get the latest nightly build. Matt Aimonetti, of the MacRuby project, reassures us that "MacRuby is namespaced and won’t affect your current Ruby installations" - but RVM is still an option, nonetheless.
Once you give MacRuby a try, check out HotCocoa too (installed with macgem install hotcocoa). It's a library that acts as a "Ruby layer" between Cocoa and MacRuby. Instead of wrestling with Cocoa's classes and verbose method names, HotCocoa wraps up Cocoa in a big, warm blanket of familiar Ruby. Take this very simple "throw a window with a button on the screen" app, for example:
require 'rubygems' require 'hotcocoa' include HotCocoa application do |app| win = window :size => [100,50] b = button :title => 'Hello' b.on_action { puts 'World!' } win << b end
Will the iPad support MacRuby?
Matt says "No." The problem isn't a lack of desire or interest, but that the iPhone OS (also used on the iPad) doesn't do automatic garbage collection or have BridgeSupport support - both of which are needed for MacRuby. Supposedly, though, contributors are looking into ways to circumvent these issues, but I'm more hopeful of GC support in iPhone OS 4.0..
[ruby inside news] Peter here! My next "big thing" is a new site called coder.io. If you're into technologies like Ruby, Git, Python, the iPhone, MySQL, JavaScript, Clojure, etc, you might want to get on the coming sooon list :-) There should hopefully be some freebies/bonuses along with exclusive early access. Thanks!
more »
MagLev Alpha Released: A New, Scalable Ruby Implementation »
Created at: 21.11.2009 04:20, source: Ruby Inside, tagged: Cool Linux Specific News OS X Specific Tools
MagLev is a new(ish) Ruby implementation built by Gemstone Systems that focuses on providing an integrated object persistence layer and a distributed shared cache - a truly scalable Ruby implementation. Maglev has, however, had an air of vaporware about it, having been hyped up in early 2008 and only available to a small group of alpha testers till now. That changes today with the first public, alpha release!
Back in early 2008, MagLev program manager Bob Walker did an interview with InfoQ about the project where he said that 8 people were working on MagLev, so this is a pretty big deal for them. Developer Avi Bryant then did a short presentation at RailsConf 2008 where he gave a comprehensive overview of what MagLev is along with some live demonstrations.
Why Should You Care?
In short, MagLev is cool for a few reasons. Two key ones being that 1) MagLev runs on the SmallTalk virtual machine which, it is claimed, should yield significant performance increases for a language like Ruby, and 2) a MagLev environment allows multiple Ruby processes over multiple machines (if you wish) to use the same objects simultaneously for easy scalability. Avi's video is great if you want to get a grasp on it:
MagLev presentation at RailsConf 2008 from Monty Williams on Vimeo.
Developer Monty Williams is keen to stress that this is an alpha, not a beta, so you can't expect it to run Rails or any gems that require C extensions. That said, it does run Sinatra, Rack, and RubyGems, plus a significant effort has been put into passing the RubySpec, so it's not as if it's a crippled implementation as such.
If you want to learn more, consider following the MagLev team on Twitter @MagLev and checking out the official mailing list "maglev-discussion."
Installation (i.e. getting to an irb prompt that works)
Bear in mind that MagLev will only work on 64 bit versions of OS X, Linux, and Solaris, so if you're in the 32 bit club, there's no point in going any further (yet).
If you download the MagLev Installer script (small ZIP file), you can run the installMaglev.sh script and install the latest version like so:
./installMaglev.sh 22578
The announcement post doesn't make it clear you need to provide a version number of what version number to provide. 22578 was mentioned earlier in the day though, and it seems to work.
Once installed, MagLev provides some info about environment variables you need to add to your .bashrc or .bash_profile. Follow these, then open a new terminal and here's how you get to an irb session:
$ maglev start
startnetldi[Info]: Starting GemStone network server "gs64ldi".
startnetldi[Error]: could not start server
startstone[Info]: Starting Stone repository monitor "maglev".
startstone[Info]: GemStone server 'maglev' has been started.
$ maglev-irb
irb(main):001:0> 20 + 20
=> 40
irb(main):002:0> exit
error , SystemExit Error, nil,
during /Users/peter/Downloads/MagLev-installer/MagLev-22578.MacOSX/bin/maglev-irb
SystemExit Error, nil
Alternatively: GitHub installation
MagLev is also available from GitHub to clone. To install MagLev from GitHub:
git clone git://github.com/MagLev/maglev.git cd maglev ./install.sh
.. then follow the note about adding the path to your .bashrc or .bash_profile and running Rake in a new prompt (though still under the maglev project directory).
If you get any further with doing something interesting like, say, getting an IRB prompt up successfully on this, do post a comment ;-)
[ad] Find duplication, code smells, complex code and more in your Ruby code with Caliper! The metrics are free and setup takes just one click. Get started!
more »
