
RubyMotion - Ruby for iOS - acangiano
http://www.rubymotion.com/
======
stephth
I love writing Ruby code, but today I'm finally at a point where I also feel
happy and productive with Objective-C. What made my eyes bulge is this:

[http://www.rubymotion.com/developer-center/guides/project-
ma...](http://www.rubymotion.com/developer-center/guides/project-
management/#_configuration)

No XCode. Instead of obscure and impenetrable project files, a convention over
configuration Rakefile. Clean and Ruby-like workflows and repositories.

 _While you can certainly configure an Xcode workspace to program in
RubyMotion, we do not provide any support for Xcode out-of-the-box. We do not
believe that Xcode makes a good environment for Ruby development (or
development in general). Ruby also makes it very easy to write great Domain-
Specific Languages that can be used as elegant alternatives to graphical user
interface or data modeling tools._ [1]

Laurent Sansonetti gets it. I've been writing iOS code for three years and
have never been able to figure out how to have a frictionless workflow around
XCode, everything about it is convoluted. The idea of automating frequent
development tasks with Ruby generators and DSLs sounds exciting and promising.

[1] <http://www.rubymotion.com/support/#faq>

~~~
petercooper
Which makes me wonder.. is it possible to rig up such an environment for
standard Objective C iOS app development? It could be huge.

~~~
lobster_johnson
It's entirely possible to use Make (or whatever you want) to build a project.
There's no magic to Xcode. You just need to invoke to correct compiler and
linker (Apple's GCC, usually), include the right flags and frameworks for
them, and probably invoke some Apple tools for things like code-signing.

------
jeremymcanally
This is from Laurent Sansonetti, the original author and long time maintainer
of MacRuby. It doesn't say that anywhere until _after_ you buy it, which they
should really change since that made me go from "Uh, did some random guys just
take MacRuby's code and hack in some extra stuff to sell it?" to "Holy crap so
THIS is what he's been working on!"

~~~
octopus
Actually they say that this is based on MacRuby:

<http://www.rubymotion.com/features/>

at the bottom of the page:

 _RubyMotion is based on MacRuby, a widely-used implementation of Ruby created
and maintained by Apple for over 4 years. Starting from a solid and stable
code base, the guys who originally created MacRuby now work on RubyMotion.
You're in good hands._

~~~
jeremymcanally
Ah, now I see! I suppose I glossed over that. It should be bigger. ;)

~~~
100k
I agree, I looked at pretty much every page on the site wondering what the
connection was to MacRuby, until I found it in the FAQ.

------
octopus
A suggestion for Laurent Sansonetti will be to release this similarly with the
way Xamarin has released Mono for iOS. Basically you should be able to
download and use the library for free in the iPhone/iPad simulator and you
will need to buy a license if you want to be able to export the app to the
actual device. This licensing model has the advantage that is similar with
what Apple does for developing apps for iOS.

This will let you, as a developer, try and learn to use RubyMotion before you
actually buy a license.

~~~
grey-area
I'd second this suggestion. I love the idea of using ruby on ios, this looks
like a womderful solution, and it looks far more rubyish in syntax than
Mobiruby (which isn't there yet anyway), but I would really like to try it out
for myself in the simulator and develop a few simple apps before deciding
whether I would want to use it professionally. If they could limit it to
simulator only for free it would be much easier to tell if it is going to be
really useful or more painful than just putting up with obj c. Having a demo
might even boost adoption.

A question for the developers - did you consider this option and reject it for
some reason?

------
sjtgraham
I don't see the point of this. Objective-C is not hard to learn, and with ARC,
blocks, the new literals for NSArray and NSDictionary, etc, Objective-C has
actually become pleasant to write IMO. The example RubyMotion code also
doesn't look very nice either.

The problem with Rubyists (being one for the past 6 years I feel qualified to
say this) is _in general_ they want to use Ruby for everything. It's not
always the best tool for the job.

~~~
spacemanaki
Forgive my ignorance of iOS, but do the current Objective-C based tools
deliver "An interactive shell [...] for introspection, live coding and
debugging" ? If RubyMotion can actually deliver a real first-class REPL that
works, that would be a pretty huge deal. Lack of a REPL is the biggest reason
why I dislike mobile (Android) development.

~~~
jawngee
Yes, it's called GDB or LLDB, depending on your compiler. Not live coding
though, but I don't know if that's a big deal.

~~~
YuriNiyazov
Yes, it's a big deal. Being able to live code completely changes (and dare I
say, improves) one's ability to construct rather complicated structures that
work because the small building blocks are live-tested. It's fantastic.

~~~
jawngee
And now I'm left wondering how Apple ships anything without a REPL.

It's not a big deal*

* former smalltalker

------
sant0sk1
This is really awesome, but I found some bad news in the FAQ:

> Because RubyMotion implements a dialect of Ruby that is statically compiled,
> regular Ruby gems will not work in RubyMotion. We provide documentation
> which describes how to architect gems to work with RubyMotion.

~~~
deedubaya
Anyone who has done any serious MacRuby development would already tell you
that normal Ruby gems aren't usually the best way to go (slow, don't use
Objective-C frameworks).

I can see where this could be a problem if you typically just glue gems
together to make products, but if you're used to rolling your own solutions it
isn't a big deal.

Sucks, but not a show stopper.

------
zbowling
Part of me is happy. Apple pushed MacRuby before Lion and effectively killed
it internally going forward after the ARC announcement. MacRuby relies on the
GC capability of Objective-C which is incompatible with their new ARC baby.
Just a few days ago I wanted to take a backend framework we wrote and build a
command line tool to call some of it's methods in MacRuby (lots of command
line parsing and Ruby has good facilities for that) but forgot we converted
that framework to ARC. No dice.

This looks promising but at the same time I really wish the backend compiler
was open sourced and worked on Mac and not just iOS.

~~~
hlidotbe
Since Laurent Sansonetti is the author of MacRuby AND RubyMotion, he already
said feature from RM will be backported (and hence open-sourced) to MacRuby

~~~
jballanc
I'll simply point you at Laurent's email to the MacRuby-devel mailing list
about a month ago. I think re-reading it in light of today's announcement
could be...informative ;-)

[http://lists.macosforge.org/pipermail/macruby-
devel/2012-Apr...](http://lists.macosforge.org/pipermail/macruby-
devel/2012-April/008702.html)

------
jwarzech
I've played around with what seems like ever alternative framework under the
sun (Titanium, Rhodes, PhoneGap, MonoTouch, Corona) and have been pretty
frustrated with how clunky they usually feel. However with everything its
claiming and the decent price point I'm toying with purchasing site
unseen...just wish I could try it for a few hours first.

~~~
acangiano
Two suggestions:

1) [http://arstechnica.com/business/news/2012/05/exclusive-
build...](http://arstechnica.com/business/news/2012/05/exclusive-building-
ruby-ios-applications-with-rubymotion.ars) (Review with code)

2) <http://pragmaticstudio.com/screencasts/rubymotion> (Screencast)

------
spicyj
This looks really cool -- would be nice if there was some way to try it out
before buying.

------
tommy_m
Cool free 50 min video on RubyMotion -

<http://pragmaticstudio.com/screencasts/rubymotion>

------
bherms
Just a note, not sure if this is intentional, but the audio on the video is in
stereo, but with no right channel.

edit: also, please stop the heavy breathing into the mic. Driving me crazy!!
:)

~~~
SeoxyS
I could not watch the video (on headphones) because it is physically painful
to do so. That's a _HUGE_ problem.

~~~
bherms
Exactly.

------
jballanc
Be sure not to miss all the sample code:
<https://github.com/HipByte/RubyMotionSamples>

In particular, for those looking for a side-by-side comparison of what it
means to use Ruby instead of Obj-C, be sure to check out the GestureTable
sample:
[https://github.com/HipByte/RubyMotionSamples/tree/master/Ges...](https://github.com/HipByte/RubyMotionSamples/tree/master/GestureTable)
which was based on the JTGestureBasdeTableView:
<https://github.com/mystcolor/JTGestureBasedTableViewDemo>

------
smoody
"At the end, a RubyMotion app looks _pretty much_ the same as an Objective-C
app." ( from bottom of: <http://www.rubymotion.com/features/> ).

pretty much the same as an Objective-C app? Anyone have any clue as to why
they didn't state apps in the two languages would look identical?

~~~
cschneid
Different compilers will generate different compiled code, even on identical
input (ie, clang vs. GCC). So the binary will be different.

~~~
elsurudo
I think he's commenting on why they wouldn't LOOK identical, as in UI.

UI is a finicky thing, but assuming this allows you to use all Apple APIs,
there is no reason you couldn't get an identical-looking UI using this.

~~~
cmelbye
I'm fairly sure that section is talking about compiled code, structure of the
app, the archive, etc, considering it says "compiled ahead-of-time, never
interpreted, and you access the entire set of iOS public APIs." the previous
paragraph.

You're right though, there's no reason the UI wouldn't look identical as well.

------
tobiasbischoff
nice, but where is the advantage over just using objc? the hard part of coding
for iOS isn't objc, it's learning how to use all the API's.

~~~
hlidotbe
Having been part of the private beta I can tell you that it's a huge time
saver. Objective-C is nice be ruby is much more expressive, you can use the
same API with much less code, you can skip XCode altogether and use your
favorite editor, ...

I can't express properly how awesome it is, really.

~~~
mattgreenrocks
In the Ars article, I noticed the author mentions you can't use XCode's layout
tools.

In practice, how big a problem is that?

~~~
RandallBrown
Some people hate interface builder and don't use it at all. I really like it
and would have a really hard time getting rid of it. The amount of code you
would need to write to make all of your views would be terrible.

I would liken it to not using HTML when you're making a web app and you can
only use javascript to generate (by hand) all of the UI.

~~~
elsurudo
Except that I feel the control you lost by using IB is smaller compared to the
control you lose by using an HTML builder. But then again, it's been forever
since I last used an HTML builder.

In both cases, there are border cases that need to be handled in code (or
markup).

------
jgavris
I don't understand all the hate for Objective-C, and at the same time love for
Ruby. Objective-C is far easier to read, with named parameters and types
everywhere. Ruby is often so minimal that you need to interpret the whole
program yourself to understand what's going on...

------
e28eta
The most exciting part of this for me is the automation and integration with
Apple's tools.

For instance, built-in TestFlight rake task, or build and run on
device/simulator. I'd love to borrow some of that for a CI build system (which
for me is currently a large shell script that could be improved on).

I'm also very interested by the interactive REPL that can run code inside my
application. LLDB is good, but falls short for me occasionally.

------
melvinram
Will apps created using this have any problems getting approved with App
Store?

~~~
acangiano
No. From the FAQ (<http://www.rubymotion.com/support/#faq>):

"Applications submitted to the App Store must conform to the Review Guidelines
dictated by Apple. RubyMotion implements a dialect of Ruby that conforms to
those rules. RubyMotion apps are fully compiled, do not download or interpret
code and are using public iOS APIs through the exact same machinery as regular
Objective-C apps."

~~~
fourgone
I would rather see confirmation from Apple (doubtful) or developers who have
successfully submitted apps to the App Store.

------
derekorgan
Looks very promising. I love Ruby and I initially hated Objective-C but I have
to admit now I find it very powerful. The biggest missing link here seems to
be the Storyboard. Its a really nice option in xCode. Have I missed something,
how are layouts defined separately from code?

------
christiangenco
I love this. It looks like exactly what I've been looking for since the iPhone
SDK was first announced. I've been a web/RoR developer since high school but
could never find the motivation to get used to all of Objective C/XCode's
quirks. I've tried everything from PhoneGap to Appcelerator to mimicking
native feel in a browser, but it was never enough. This is perfect.

But quite frankly, I can't afford it. I'm a college student living on $25/week
for food - I can't justify spending 6 weeks of food on an experiment.

If I could try it out? If I could build my killer app first and know that it
works? It wouldn't hurt as much, but $150 is still a lot of money.

~~~
Zev
But you could justify spending 4 weeks food on an experiment? Because you'll
need that $100 to put an app on your device, as well.

~~~
christiangenco
Ahh yes, that's not particularly fun either.

------
robomartin
I am not criticizing. This is a perfectly neutral question:

Isn't the issue with a lot of these "look Ma, no Objective-C" approaches in
that there are always little nagging issues here and there?

I mean, Apple is constantly moving Objective-C/Xcode/iOS (notice I didn't say
"forward"). Isn't it somewhat dangerous to adopt peripheral approaches for
development rather than staying (suffering?) with the Apple-provided tools?

Now, if someone has an alternative IDE that truly allows me to record Xcode to
a DVD and perform a ritual burning ceremony of said DVD...that would be
something.

~~~
aiscott
I said this in another reply, but I'll reiterate here. It's not the lack of
Objective-C that is the big deal here. Afterall you are still interfacing with
cocoa, and are stuck with a lot of the verbosity in doing that.

The _real key_ to this is the REPL and interactivity between coding and the
_running_ app. Being able to edit bits of functionality and structure in the
running app, and immediately see the results is AWESOME!

~~~
robomartin
I don't know Ruby. Therefore, by my own admission, this comes out of complete
ignorance.

I am currently working on a project that uses a genetic solver and some fairly
complex state machines driven by fairly involved databases. I can't possibly
see how something like this could be made to be interactive in terms of the
development process. Generally speaking you are writing a lot of code before
you get to compile and see the results. And, personally, I don't have any
issues with the compilation process.

What do you mean by "interactive"?

~~~
kcbanner
Your application is something that doesn't lend itself to the problem that
this solves. With UI related things, it is often very helpful to be able to
tweak UI elements while the program runs, instead of the tweak, compile, run
cyle.

------
octopus
This is huge from a programmer productivity perspective.

------
sunjain
Now there is an alternative to Objective-C in iOS development(for Rubyists).
This is similar to development of Coffescript. There is nothing wrong with
Objective-C, it is just that folks who prefer the elegance and beauty of Ruby
have an option. I think this will be great combination - beautiful & elegant
language for creating apps on a beautiful platform.

------
instakill
Are there any example apps in the wild that were made using RubyMotion?

~~~
jamesjn
There's a few example rubymotion apps at:
<https://github.com/HipByte/RubyMotionSamples>

I find them really easy to follow.

------
drpancake
From the screencast it looks like they altered Ruby syntax by adding named
parameters to conform with Obj-C's way of specifying prototypes. I guess this
is a trade-off for the fact that Obj-C has some unusual syntax that has no
real analog in Ruby -- if you've ever tried developing with PyObjC you'll be
familiar with how odd it looks.

------
anuraj
Problem in search for a solution? Apple is walled garden - provides the best
integrated IDE for iphone development that is a pleasure to use. Language is
just a small part of the puzzle. For each task, the best suited environment
and language. There is no panacea.

------
toisanji
How does memory management work with ruby and iOS? I did not find the
information on the website.

~~~
acangiano
From the Features:

"It's Ruby, you don't need to think about managing memory. Ever. RubyMotion
will by itself release the objects you create when they are no longer needed.
Our memory model, similar to Objective-C ARC in design, does not require any
extra memory or processor footprint to allocate and reclaim unused objects."

~~~
webjprgm
I still wonder how they did that. The classic problem with reference counting
is correctly releasing cycles, which ARC handles by allowing "weak"
references. How does MacRuby know when to insert a weak reference as opposed
to the usual "strong" reference? If that could be automatically detected, why
does Obj-C ARC not automatically do it for you?

~~~
chc
"Object cycles, when two or more objects refer to each other, are currently
not handled by the runtime, but will be in future releases."

So, basically, you're stuck with retain cycles right now. My bet is that they
implement a way of marking weak references rather than becoming more
intelligent than ARC.

~~~
smparkes
I wonder how big a deal this will be. Relying on GC feels like it goes hand in
hand with dynamic languages. I'm used to not having to worry about cycles.

Of course, I guess I'm use to not having to worry too much about memory,
either ...

Weak references aren't a panacea. It's not that uncommon to have cycles where
all edges are equally strong. Any social graph ...

I use use counts to collect those cycles. ARC doesn't let you use use counts,
but you don't have to use ARC everywhere. You do have to access to the
underlying use counts ... MacRuby should allow access to that (it's just a
standard Cocoa call) as long as it doesn't keep stray retains around that
screw up my count balances ...

~~~
chc
You can still use counts — you just can't use Foundation's retain count.

And I think CoreData is the answer to problems like a social graph. It does
its own specialized memory management. But you're right, it's awkward to have
to think about it.

------
cm_richards
Ruby :

"The limits of my language define the limits of my world" if string =~
/foobar(\d _\w)/#

Objective-C :

    
    
      NSError *error = NULL;
      NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"foobar(\\d*\\w)"
      options:NSRegularExpressionCaseInsensitive error:&error];
      NSTextCheckingResult *match = [regex firstMatchInString:string
                                                    options:0
                                                       range:NSMakeRange(0, [string length])];
      if (match) {
        NSLog(@"The limits of my language define the limits of my world - Wittgenstein")
      }
    

Enough said?

------
typicalrunt
What's with the price difference between Canada and US orders? It's CAD$152.82
versus US$149.99.

With the Canadian dollar currently worth about 1 cent more than the US, I'm
surprised to see that there is a price difference at all.

~~~
jamie_ca
The nominal exchange rate you see has only a passing resemblance to exchange
rates charged by CC processors.

------
EternalFury
I'll say this again: No programming language is fundamentally bad.

Bad programmers have a tendency to move from language to language, blaming
their tools for their lack of skill.

This stuff is exciting.

~~~
jbrechtel
I wholeheartedly disagree. There are bad programming languages. Brainfuck is a
good example. I don't mean that as a joke, but only as proof that programming
languages can be objectively bad. As an extension of that I'd say that
languages can be bad because of their constituent parts (syntax, semantics,
constructs, features or lack of, etc..).

Some languages have constituent parts that I'd say are objectively bad. I'll
argue all day that Objective-C's handling of nil is stupid beyond belief.
Nil/Null itself is bad enough...

------
jstepien
At the very beginning of the presentation he underlines the importance of the
static compiler RubyMotion is based on, yet at 7:30 when he compiles a file
with a name error in it the compiler doesn't even file a warning. Such non-
existent methods and other similar errors should be caught at compile time if
we're talking about solid AOT compilation.

------
pepijndevos
I thought Flash got in trouble for targeting iOS with something not
_originally_ written in JS or ObjC, is that still true?

------
dmitryso
I don't remember the last time I was excited about some new technology, but
rubymotion is a thing I was looking for since the release of iOS SDK. I was
doing ruby for 5 years, and switched to iOS/ObjC half a year ago, and I still
can't stand the Objective-C syntax.

------
vldo
missing trial period so i'd rather wait for mobiruby

~~~
jballanc
The difference is that, as far as I can see, mobiruby is a Ruby interpreter/VM
embedded in an Obj-C application. This is in contrast to MacRuby which is
implemented directly on top of the Obj-C runtime. So, MobiRuby still has to go
through the work of converting Ruby objects into Obj-C objects, whereas in
MacRuby a Ruby object _is_ an Obj-C object.

For a practical example of what this means, see the most recent sample code
that was released for mobiruby: <https://gist.github.com/2577620>

------
tlear
No interface builder? Depending on what type of apps you make it can be a big
issue I think

~~~
malyk
The problem with interface builder is that it only exposes some properties and
others you have to set in your class anyway. Why can't I set the background
image of a view in interface builder, for instance?

With RubyMotion you get to roughly lay out your controls, and then you get to
use the interactive interpreter for fine-grained adjustments. See around the
5:30 mark in the getting started video for an example.

------
sthulbourn
It's nice, I'm new to using ruby (I've been an iOS dev for a while now), I'd
give it ago.

But I assume it uses storyboards in the same way as ObjC, set it in the target
and in the Info.plist, and it figures it out... it'd be nice to see it working
though.

~~~
botj
I second this.

------
guynamedloren
> _RubyMotion is built on top of iOS. You have access to the entire set of
> public iOS APIs and can also use 3rd-party Objective-C libraries or Gems_

So this should be compatible with cocos2d right?

~~~
octopus
cocos2d is writen in Objective-C so in principle it should be compatible with
RubyMotion. Not so sure about the ARC integration (last time I've checked
cocos2d was only "ARC compatible"). I've seen some work arounds using a
cocos2d as a static library (no ARC enabled) linked with a main Objective-C
application that uses ARC. It should work ... but I can't give you a final
answer.

------
ScotterC
I could see this really taking off.

My worry is that it would take off so well that the ruby gem community could
get fragmented into libraries for RubyMotion and libraries for regular ruby
projects.

~~~
cheald
There are already exclusive libraries for MRI/JRuby, so adding a third
platform doesn't seem like it would break the world. Tools like Bundler do a
great job of keeping things moving smoothly.

~~~
ScotterC
Didn't realize bundler kept track of what ruby you were using.

~~~
cheald
Yeah, check the "platforms" directive.

------
funkyboy
I am wondering is anybody asked for a debugger/stepper. Will a dev survive
without those? Also, are you ready to write all the code behind xibs?

------
davidrupp
Purchased. Good job, @lrz. Glad to know your departure from Apple and
(apparent) distancing from MacRuby were in a good cause.

~~~
superalloy
He did not distance himself from MacRuby, though:
[http://lists.macosforge.org/pipermail/macruby-
devel/2012-Apr...](http://lists.macosforge.org/pipermail/macruby-
devel/2012-April/008702.html)

------
ef4
What annoys the crap out of me isn't objective C, it's XCode.

This looks worth it just to have an XCode-free toolchain.

------
daniel_sim
Should make for some good bridge FU on hypercritical this week...

------
damian2000
Sounds awesome - gives me another reason to buy a Mac.

------
hemancuso
Anyone know if this comes with the ruby stdlib?

~~~
dmarkow
It doesn't look like it. You need to use the iOS alternatives (in this case,
NSDate).

    
    
      (main)>> require 'date'
      => #<RuntimeError: #require is not supported in RubyMotion>
      (main)>> Date
      => #<NameError: uninitialized constant Date>

------
riffraff
anybody understood what rubymotion offers over the standard macruby? edit: got
it, static compile and no gc

------
TheSmoke
so, we need a mac for this. right?

~~~
wmboy
Yes... "You will need a Mac running OSX 10.6 or higher."

\- <http://www.rubymotion.com/support/#faq>

------
freditup
My thoughts: "Hey! This looks pretty neat. Oh it's $150 on sale, forget this.
Oh it's only for macs, glad I never bought this piece of garbage."

That being said, it could be great, I have no idea.

~~~
lectrick
Maybe that's because Macs don't generally deal with pieces of garbage. Whether
that's tools, or users.

~~~
freditup
If you really think one platform is so superior to another, you're missing the
point entirely.

------
shapeshed
There's a reasonably new language called HTML that is a good development
platform too. Works on all devices.

~~~
michael_f
"Good" and "Works" being relative terms, of course. YMMV, especially amongst
devices in the installed base where web views aren't GPU-backed (e.g, on one
common platform, that being the vast majority).

