Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

What I’ve learned about RubyMotion

JT Archie
Wednesday, August 29, 2012

I’ve been trying to learn RubyMotion recently, using Ruby to develop iOS appeals to me.

I have no prior Objective-C or Cocoa API knowledge besides the basic HelloWorld. I’ve been using this tutorial and have learned more about Cocoa API faster using Ruby than with Objective-C. There is less boilerplate code that needs to be written for defining interfaces and implementations.

The main takeaway of RubyMotion is that it is not your standard Ruby implementation. It is a Ruby runtime wrapped around the Objective-C runtime. All Ruby objects map directly to there corresponding Objective-C object — Array to NSMutableArray, Hash to NSMutableDictionary, etc. RubyMotion does not come with the standard library as other flavors, you are relying on Cocoa API as the standard library.

There is even a difference in Ruby syntax to map directly to Objective-C. The Objective-C language does message passing for “method invocation”. This means that a method call on an object is determined by parameters rather than just method name. RubyMotion had to include this language feature, so you will actually see Ruby that is invalid all other Ruby flavors.

class MyObject
    def doSomething(doSomething, argument: argument)
    end

    #This does not override the method defined above
    def doSomething(doSomething, anotherArgument: argument)
    end
end

Luckily there are extensions for your favorite editors. Rubymine even supports MacRuby syntax, but does not support autocomplete, yet.

Two weeks ago, I saw a talk about RubyMotion from its creator in Berlin. He gave the basic HelloWorld demonstration, but also gave an introduction in the community. It is small, but great things are coming out of it.

The community has started taking the power of Ruby and making the libraries and DSL-y things we love in Ruby.

  • BubbleWrap is a resource API. It gives you easy access to JSON parsing, HTTP requests, alerts, etc. It is kind of catch all of lower-level Cocoa API tasks that you don’t want to have to write your own helpers for.
  • Formotion is a DSL to create Forms. Usually you use Interface Builder to build forms and load the appropriate NIB. This gem will allows you to define a form in code.
  • MotionData is ActiveRecord like access to CoreData. It supports migrations, scopes, basic validations, etc.
  • SimpleView provides a DSL for formatting views.

With all this, there is one question that always gets asked. Is RubyMotion worth it? Yes! Laurent, the creator, is in it to win it! This is why he charging for the RubyMotion; funding ensures that he can continue to work on it.

From a Pivot role, I’ve had to discover RubyMotion’s position in testing. Pivotal Labs is a pure TDD shop, everything from Java, Objective-C, Javascript, and Ruby is tested.

RubyMotion comes with a prebuilt RSpec (actually a port of bacon) like testing framework. The testing framework supports the testing of views and controller using the UIAutomation framework. I think that we can agree that it could be better, but I believe there is enough to get started and allow us to expand on it.

The RubyMotion community is still growing. I look forward to see what comes out of it, so that I can use Ruby in other devices.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

2 Comments

  1. Alex Koppel says:

    Thanks for the blog post! I’ve had a low-grade burning desire to try RubyMotion for a while, and I think it’s time to take the plunge.

    Knowing that it’s a thin wrapper around the Objective-C libraries is useful. I wonder if it’d be a worthwhile project to try to port chunks of the Standard Library to RubyMotion, or if that’s an unnecessary layer obfuscation…

    August 30, 2012 at 12:18 pm

  2. Colin McCloskey says:

    Great musings on your first look into RubyMotion! I’m intrigued by the possibilities of using RubyMotion for native iOS development instead of going through the PhoneGap/Apache-Cordova approaches.

    August 30, 2012 at 12:35 pm

Add New Comment Cancel reply

Your email address will not be published.

JT Archie

JT Archie
New York

Recent Posts

  • [NYC][Standup] 09/27/12: Protect all your attributes
  • [Standup][NYC] 09.24.2012 Moral support for the pub and sub
  • merging scopes with STI models
Subscribe to JT's Feed

Author Topics

agile (5)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >