« Quick thoughts on the Safari 4 betaThe new footer »

The problem with Ruby bridges

So, my PluginManager hasn’t been updated in 18 days or so. It’s not for lack of working on it, it’s because I’m embroiled with getting the Ruby plugin to actually work. I know that I published it with Ruby support, but it doesn’t really work. Not really. I’ve been messing with the various Ruby bridges and figured I’d offer a few thoughts.First, let’s get the easy one out of the way: I’ve never used RubyObjC. I’m a big fan of Nu which is also written by Tim Burks, but never looked at RubyObjC. I understand that Nu superseded RubyObjC and it wouldn’t be developed for anymore so I decided not to bother with dead code.

MacRuby may be the future of Ruby on the Mac. It has the backing of Apple and is built on top of the Foundation framework. However, it’s rather unwieldy to incorporate into any other code base. It’s unwieldy for this reason: it uses Apple’s Objective-C garbage collector. This means that every app that incorporates the code must either use the GC or flip a switch to make it available. This isn’t an insurmountable task, but it’s still a pain. It also doesn’t provide a wide range of convenience methods that’d make my job a whole lot easier.

RubyCocoa is pretty much the de facto standard for Ruby bridges and one that I appreciate and hate at the same time. It provides several nice convenience methods which I appreciate but it is also really buggy. It is especially buggy when integrating with other frameworks. Still, it’s gotten me closer to having a plugin system than the other bridges. Unfortunately, there’s a rather significant problem. If you run a script without importing the bridge from the script, your app will crash when trying to pass in ObjC objects. However, if you import the bridge, it substantively changes how the script works. It isn’t the same type of script object if you import the script. This is a rather troublesome pain in my ass.

So, I’m working on fixing these issues, but it isn’t going quickly. I’ve worked a bit with MacRuby and then came back to RubyCocoa. I may flip back and forth for a bit before inspiration hits and I’m able to get it to work. Anyway, I’m working on it and would appreciate any help if someone is knowledgeable about the frameworks.

Leave a Reply