

The RubyMotion Way - 10char
http://clayallsopp.com/posts/the-ruby-motion-way/

======
flatline3
> _Rubyists get a lot of flak for the kind of DSLs and black magic
> method_missing tricks the above libraries use; but you know what, maybe that
> attitude is just what Objective-C has been missing._

I politely disagree. Objective-C hasn't been missing risky and error-prone
approaches that merely attempt to save a few characters at the cost of
correctness. Extensions like 'when' are vague, and could just as easily be co-
opted for KVO as they could for UIControl event handling.

Also, the example is not accurate. In Objective-C, you'd control-drag from the
button to your action method, using Interface Builder.

~~~
10char
I think the value add of a `when` style isn't saving keystrokes but improving
readability. What happens when the event fires is right there in-line with the
button, not somewhere else on the page. Yeah there are editor tricks to
command+click to it and such, but that's still some overhead.

TBH I think it really is a matter of preference at this point. There could be
a killer, must-use RubyMotion framework in the future, but for now I simply
feel more productive and flexible in Ruby.

In fact, the most impactful change of RubyMotion (and I somehow neglected this
when I wrote it) is testing. It ships with a really powerful port of Bacon
which is lightyears better than UIAutomation, KIF, and every other iOS testing
framework I've tried. `rake spec` is a seamless, regular part of my workflow
in a way that Xcode failed to achieve.

~~~
flatline3
> _I think the value add of a `when` style isn't saving keystrokes but
> improving readability. What happens when the event fires is right there in-
> line with the button, not somewhere else on the page. Yeah there are editor
> tricks to command+click to it and such, but that's still some overhead._

With Interface Builder, there is no "right there in-line with the button",
because the button (and the entire remainder of the layout) is instantiated
and fully laid out in a nice WYSIWYG editor.

That said, as the you noted, you _can_ do this in Objective-C. However, due to
the propensity for conflicts, it's bad form to insert un-prefixed category
methods into system classes.

This is an appeal to emotion, but I must be honest: I'm concerned about the
day that I'm asked to take over maintenance of a Ruby Motion project,
especially if it's likely to diverge significantly and arbitrarily from our
community's existing best practices.

------
smoody
" If you've tried projects in Ruby and just didn't like it, RubyMotion
probably won't change your mind. But if you've ever wanted to make iOS or Mac
apps but didn't want to get over the hump that is Objective-C, maybe this will
get you going."

Can RubyMotion itself be used to create Mac apps in addition to iOS apps?

~~~
10char
Sorry, should have specified! As jballanc said, I was referring to MacRuby
(<http://macruby.org/>). I'll add a link there for clarification.

RM and MR are both by Laurent Sansonetti, and the experience developing for
them is identical. The Ruby code is just as portable as Objective-C between
iOS and OS X. I'm working on something right now which uses both technologies
and it's been a great experience.

~~~
objclxt
There is, of course, one important different between MacRuby and Ruby Motion:
the former is GPL compliant, and the latter is commercially licensed.

I think this is a shame, because I suspect lots of people would quite like to
contribute back to the project, and that's currently not an option.

~~~
hlidotbe
Of course it's a shame that Laurent needs to eat and of course this has
everything to do about RM being able to build for Mac or not. Knowing him, I
know he would prefer RM to be open source but it would be much harder for him
to monetize his efforts.

I'm perfectly ok with paying a fee to get RM but I know that wouldn't pay for
support (especially if the community handles it which is already the case).

Corporate sponsorship doesn't always works and often lacks security and
stability for both the developer and the project as they are at the mercy of
one entity.

~~~
veyron
He would make more money charging for support or for the tail end (e.g.
codesigning).

------
DarwinOS
I sometimes wish rubymotion and macruby had named parameter with default
value, something like

def functions(with, this: syntax="default value") end

but over all, I think rubmyotion rocks and I hope and brings some great
Objective-c/Cocoa world into ruby-world and vice-versa.

~~~
learc83
You can setup your method to accept a hash, and then do something like this...

syntax = options[:syntax] || "default value"

...in the method body. Still, it would be nice to have it built in.

------
mapgrep
If you want a deeper dive into RubyMotion, the creator was just on The
Changelog podcast -
[http://thechangelog.com/post/25928209107/episode-0-8-2-ruby-...](http://thechangelog.com/post/25928209107/episode-0-8-2-ruby-
motion-macruby-and-more-with-laurent)

He actually left Apple to launch RubyMotion -- a commercial product, by the
way -- after creating MacRuby and developing/maintaining it for several years.

------
dogan
iOS development is not only objective-c and Cocoa Touch. XCode, interface
builder, instruments are also big helpers and sometimes there can be memory
problems that you can only trace with instrument.

~~~
marknutter
That's if you like using interface builder. I personally dislike it and prefer
to lay things out programmatically, but this probably has to do with the fact
that I came to iOS development from the web development world.

~~~
dogan
I also try to not use IB most of the time, but especially if you are building
not so custom designs, IB really increase the productivity and keep the code
clean.

------
petercooper
Why the tricky horizontal scrolling on this page? (In Chrome and Firefox, at
least. Oddly, Safari presents it as a regular vertical page..)

~~~
10char
It's because of a media query that responds to wider window sizes, strange
that it didn't register in all your browsers (it does on my Safari when I
fullscreen)

It's supposed to help readability while maximizing screen use in those cases
(instead of either stretching out paragraphs to two lines or centering the
body as to take up only a small percentage of the window). I'll change it to
trigger on a wider dimension, sorry!

~~~
petercooper
Aha, that would explain it. I almost never use Safari so its natural size is
likely somewhat thinner than my day to day browser :-) I was _just_ over your
~1300ish pixel width.

------
danso
Are there examples of products that were developed with RubyMotion?

~~~
cnp
This is a pretty mindblowing app example which is on it's way to the app
store: <http://clip.ignition.hk/>

Lots of low-level stuff there, which is very very impressive.

~~~
21sappers
That is a very cool app. Thanks for sharing the link!

------
Void_
> (after the code preview) Pretty nice right?

Yes, very nice. And also very annoying.

Using these little shortcuts everywhere is confusing. There is no order in
things.

ObjC is beautiful. There are classes, instances, methods, blocks. And
everything has its place.

This is a mess, Rails is a mess, most of Ruby code is a mess.

Proceed with the downvotes.

~~~
thmzlt
Proceed with the semicolons.

