Skip to content

A Review of RubyMotion in 2015

Gavin Morrice

Written by Gavin Morrice on January 28th, 2015 14:17

Type caption for image (optional)

RubyMotion is a toolchain that allows developers to develop native iOS, OS X and Android applications in the Ruby programming language. But is it the right choice for your next project?

In this post, I’ll cover some of the reasons why Katana Code endorses RubyMotion, and why we hope more development teams and startups will follow suit.

A Brief Background of iOS App Development

Since the first launch of the iPhone and its iOS operating system, the default choice for iOS app development has been Objective-C.

Objective-C is a variation of the C programming language, one of the oldest and most popular programming languages in use today.

iOS developers traditionally would develop their applications using Objective-C, C, and sometimes C++ within Apple’s development program “Xcode”.

C and its variants are compiled languages. This means that a program written in Objective-C is compiled, or translated, into special command codes that are optimised for specific hardware. These command codes are collectively called Machine Code, and are very fast to execute (although almost impossible for humans to work with directly).

That said, Objective-C is also notorious for being a very verbose, and unforgiving language, making it very tedious and slow to work with. This hampers development and makes changes and reworks quite expensive to implement.

“Apple’s official solution for creating iOS apps requires developers to write Objective-C. Objective- C, specific to the Apple ecosystem, is widely considered verbose, temperamental and challenging to utilize when compared to other programming languages (Scala, Ruby, Python). Consequently, iOS development using Objective-C is often slower and more frustrating than development for other platforms.”
- Gabe Sumner, Huffington Post

Another key drawback of Objective-C and Xcode (the program Apple offers to develop Objective- C programs) is they are only useful for creating iOS or OS X apps — not Android, Windows or Blackberry apps.

Until very recently, Xcode was buggy, would crash often, and felt quite restrictive to many developers. Version control in Xcode was difficult and so often done poorly (this is an essential part of working on a large project).

“There’s really no other way to put it. How many of you have had Xcode crash for no particularly good reason? And crashes are just the most common errors.”
“Xcode’s user interface is nightmarishly complicated. Clutter doesn’t even begin to describe it.”
Josh Symonds

In short, we used Objective-C because demand for iOS apps was high, and there was no reasonable alternative.

Current Approaches To iOS App Development

In November 2014, Apple released a new language called Swift to address the complaints of Objective-C. Swift, as the name suggests, was designed to be fast and much more succinct than Objective-C. Apple claims it is up to 2.6 times faster.

Since 2007, a few independent alternative tools have also been released that also allow for iOS and Android app development: Xamarin, Cordova (PhoneGap), Sencha, Steroids, and RubyMotion to name a few.

All of these solutions can be split into two distinct categories: Those that create native apps, and those that create an app-like experience. The key distinction is that a native app utilises the device’s own, inbuilt (native) software to present features such as buttons, scrollable lists, and images, whereas a non-native app is technically more like an interactive webpage that behaves like an app. Apps in the latter category are usually perceived as being of much lower quality by users.

What is RubyMotion?

RubyMotion is an established tool already used by thousands of businesses to create iOS, Mac OS X and Android apps using the Ruby programming language. RubyMotion falls into the former category of being a toolkit that creates native applications. RubyMotion, Objective-C and Swift are the three solutions that offer truly native iOS app development.

RubyMotion is not the same thing as standard Ruby (known as MRI)! When developers talk about “Ruby” they are usually referring to the MRI version of Ruby. Programs written in MRI are not compiled to a Machine Code file, but are interpreted; code is evaluated and compiled to Machine Code as it’s expressed, in real-time. This makes MRI Ruby slower and not appropriate for mobile app development.

RubyMotion allows developers to write apps written in a Ruby dialect that behaves almost exactly the same was as MRI Ruby does, but creates a compiled app file, just like Objective-C or Swift would with Xcode.

For all intents and purposes, RubyMotion apps should be indistinguishable from apps written in Objective-C or Swift.

RubyMotion apps have full access to all of the native features and libraries available in Objective- C.

Who Created Rubymotion?

RubyMotion was created by Laurent Sansonetti, a senior software engineer at Apple for 7 years who worked on Apple’s own OS X operating system. Sansonetti created MacRuby — a solution released by Apple to allow developers to create Mac applications written in the Ruby programming language. Sansonetti later left his position at Apple to create Rubymotion and release it as a commercial product through his own company HipByte.

Why Was Rubymotion created?

As previously stated, Objective-C is notoriously slow, very verbose, and unforgiving to work with. An idea that can be expressed in just one line of code in another language (such as Ruby or Python) may require several lines in Objective-C.

To understand the difference between writing code in Objective-C compared to writing for the same function in Ruby, compare the following two code samples:

Objective-C

int array_tot = [self.myQuotes count];
NSString *all_my_quotes = @"";
NSString *my_quote = nil;
for (int x=0; x < array_tot; x++) {
my_quote = self.myQuotes[x];
all_my_quotes = [NSString stringWithFormat:@"%@\n%@\n", all_my_quotes,my_quote];
}
self.quoteText.text = [NSString stringWithFormat:@"%@", all_my_quotes];

The above code sample was taken from an iOS tutorial on RayWenderlich.com — a top iOS development tutorial site.

Ruby

all_my_quotes = ''
myQuotes.each { |quote| all_my_quotes << "\n#{quote}\n" }
quoteText.text = all_my_quotes

The same 8 lines of Objective-C code are expressed in only 3 lines of Ruby — and the Ruby lines themselves are neater and shorter. Objective-C would also require an extra file called a “header file” to describe the content of the code shown above.

Code written in RubyMotion is almost invariably more succinct than the same idea being expressed in Objective-C, without any loss in meaning being conveyed to the device. The difference is not perceivable by the end-user, but is hugely relevant to the developer.

“I want to make something abundantly clear. RubyMotion is awesome. I have launched many apps using RubyMotion… Apps made in RubyMotion are just as fast and responsive as their Objective- C and Swift counterparts.”
- Jordan Maguire, TFG

Code written in Ruby is quicker and easier to change. Being able to make changes quickly is essential for a small startup company, especially when the idea being developed is constantly evolving. The cost of experimenting is reduced, as is the cost of making a “wrong” decision.

Are there any features of Objective-C That Do Not Apply To Rubymotion?

No. As stated on the RubyMotion website:

“RubyMotion apps are essentially the same as Objective-C, Swift or Java apps, as they run on top of the exact same runtime technologies and are also compiled into optimized machine code. You get to access the entire APIs set of the platform you target.”

Are there any features of Rubymotion that do not apply to Objective-C?

Including Objective-C and Swift Libraries

RubyMotion also offers developers the option to import Objective-C or Swift code into their RubyMotion application. If a developer has some Objective-C or Swift code from elsewhere that they wished to include in a RubyMotion project, they could do so without any issues.

Apps written in Objective-C do not allow developers to import Ruby code.

Portability

RubyMotion offers developers, for the first time, the chance to write native code that is largely portable from one platform to another.

Within an application, code can be considered either part of the framework, or part of the business logic. Framework code is specific to the platform the code is being run in, whereas business logic is specific to the app itself. For example: In an app that sells shoes, there will be code that defines what a Shoe is, and there may be code that shows a “buy now” button on the screen. A Shoe will be defined in the same way, regardless of whether the app is a website, iPhone app or Android app, whereas code to show a button on screen will be different for each platform.

In this example, a Shoe is considered business code, and the button code is considered framework code.

Business code may make up around 30–50% of an application’s codebase.

If a website is built using Ruby (Ruby on Rails or Sinatra) then much of the same business layer of code can be shared between that website and its iOS app if that app is also written in Ruby. Not only does this reduce the time taken to develop the software, it reduces the cost of any changes to be made, as one can change the code in one place, rather than in each platform.

Code written in RubyMotion can be shared between a web app, iOS app or Mac OS app and Android app in a way that is not possible with Objective-C or Swift. RubyMotion makes it possible to share code between web, iOS and Android apps, for the first time.

Android App Development

Android apps are typically written in the Java programming language. Though not as infamous as Objective-C, Java also can be slower to work with because of its more verbose syntax.

Apple’s Xcode and Objective-C/Swift toolkits do not support Android development

“because Swift, like Objective-C, is only relevant within the Apple ecosystem it encourages developers to commit exclusively to Apple and neglect other platforms. This is clearly a good outcome for Apple, but it’s a bad outcome for developers wanting to engage as many people as possible.”
- Gabe Sumner on Huffington Post

RubyMotion also allows developers to develop native Android apps faster and more effectively.

Notable Examples Of Apps Built Using Rubymotion

Basecamp

Basecamp is the most popular project management tool in the world with over 15,000,000 users. It was developed by 37 Signals — whose founders are also famous for developing Ruby on Rails (one of the most popular web development frameworks today); their books Getting Real and REWORK, best-sellers on the subject of startups and innovation; and being listed in MIT’s Technology Review as one of the 12 Top Innovators Under 35.

Jimdo

Jimdo is a website creation and hosting service based in Germany that has been used to create over 10 million websites. Their iPhone and iPad apps are written in RubyMotion and were selected as the “Best of 2013” by Apple.

A Dark Room

A Dark Room is a remake of a text-based role-playing game built for iOS using RubyMotion. The app was the #1 selling paid game in the App Store in both the US and UK for several weeks.

Bandcamp

Bandcamp is an online music store and a platform for artist promotion. Since Bandcamp’s web app was written in Ruby on Rails, the team have leveraged the ability to share code between their web-app and mobile app in a way that would not be possible without RubyMotion (as described above).

Summary

RubyMotion was developed by one of Apple’s senior engineers, after spending 7 years working on Apple’s own operating system, and 3 years developing a Ruby solution that would allow for more pain-free app development. It is a very well designed, well thought-out piece of software.

Apps written in RubyMotion perform equally as well as apps written in Objective-C or Swift, and have received high praise from both users and Apple itself.

By offering a better development environment for Android apps, and because it allows developers to share the same code across multiple platforms, RubyMotion allows faster, cheaper, and easier expansion into the Android market than is possible with Objective-C or Swift.

RubyMotion has so far proved itself as a wise, future-proof investment for Katana Code. Each new release offers more and more features that enable faster development, support for more platforms, and tools to help bridge the gap between the “old ways” and the new. Thousands of other companies have already seen the advantages of using RubyMotion, including some of the most respected innovators in our industry.


If you enjoyed this, you might also like:

Typewriter2

Simple, Clean Persistence in Rubymotion with motion-persistable

Written by Gavin Morrice

Page 1 n d7rv2wlmhjkucnldwnfg

Why you should build your web startup using Ruby on Rails

Written by Gavin Morrice

Page boots

The Four Tenets of Bootstrapping a Tech Startup

Written by Gavin Morrice

0*zpz7pzsfr 96c9yq

Interview with Ian Isherwood, CEO of DateME Kenya

Written by Gavin Morrice

Page splash app starter splash

App Starter now available in the App Store

Written by Gavin Morrice

Typewriter2

How Much Does It Cost To Develop An iPhone App?

Written by Gavin Morrice

Page depositphotos 60240341 original

Where To Find Funding For Your Startup Business?

Written by Gavin Morrice

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more