waffle

Ruby Wednesday

Cocoa knocked on my door. I opened, and it stepped in. It scratched its feet against the carpet and glanced down briefly. “Look…”, it went. “I’m sorry about the whole ‘C-based’ thing. Didn’t want to insist, but it was all I knew. You never wanted that, did you?” I nodded. “Here.” It handed me a package. “This is early stuff, alright? More like the way you wanted to do it. I mean, there’s no good autocompletion…” It flashed a smile, but something was different. “You noticed. Removed my braces… I think this is something you’re going to like.”

I’ve been trying MacRuby for the past few days — it’s Ruby, draped on top of the Objective-C runtime, so every Ruby object is secretly an NSObject, and everything else works just as you’d think it would. About twenty minutes in, to the extent that I love programming, I loved programming in MacRuby. It feels like the prelude to this post really happened. Everything I love about Ruby is still there. Everything I love about Cocoa is still there. I looked up about three sentences of documentation for reference. Everything just worked.

Well, mostly. MacRuby is a very young project, and it’s more ambitious than the existing bridges. (I’m not even sure whether it’s a bridge anymore.) It seems like the more code I write the more stubs I fall over. I can’t require 'json'. I can’t use variadic functions (and the method call syntax makes me wonder how variadic methods will work). Bytestrings are a mess and won’t work well at all — you’ve just got a string all of a sudden that will work just fine unless you want to get at its length or individual characters, or concatenate it somewhere unfortunate.

But these are details. If I had a penny for every time I’ve fell over some sort of project that was really solid in its implementation, but that I just didn’t like or couldn’t work in, I’d have so many pennies, I’d fill — oh, nevermind. MacRuby is the opposite of this in that it gets the fundamentals shamelessly right from the beginning. There’s still culture shock. The Ruby and Cocoa worlds are colliding, just as I thought. But in the meantime, I find I have to unlearn how bridging traditionally works in many aspects.

I wouldn’t switch over production code to this. I can’t. I’ve tried, as you might have imagined. It just doesn’t work right now. But the model works. As good as Objective-C is, I can certainly stand to see this improve over time. It’s brilliant.

Moreover, I advise that the iPhone software platform must be opened.

No comments yet.

Leave a comment

Your e-mail address is never shown. If you type a line break in the comment, it will show up as a line break (naturally). The following HTML is allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)


Please note: Your comment will not show up at once. Unless you're spamming or being abusive, you have nothing to worry about. (Read the full policy.)