485 points · by acangiano · 14y ago · 240 comments
http://www.rubymotion.com/developer-center/guides/project-ma...
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.
I dabbled in Obj-C over the years and jumped on the iOS dev bandwagon as soon as the first SDK was available. It was a long journey and coming from Ruby, I was very resistant. Once you're used to succinct syntax, it's really hard to use something as wordy as Obj-C (this was the main reason I never went back to Java). But over the years I came to appreciate Obj-C. I loved the speed and I clearly knew mobile was gonna be the next real fun thing to work on.
And that's where I've been the past 4 years, iOS land. I'm pretty comfortable now with Obj-C and the iOS framework and have worked on a number of projects in the app store. I can really say that I've seen all levels of crappy to great code. But last night when I went thru the samples of the Ruby Motion stuff, I was a little flabbergasted. I'm (now) so used to XCode code completing long method names and when I saw the Ruby equivalent and how condensed everything was, it kinda blew my mind again. I found myself thinking "whoa, that's right, there's no interfaces" when looking at the accessors (omg, so much less code vs. using typical ivar properties) and just all these little Rubyisms that I'm not used to seeing with iOS. It totally made me smile. Oh yah and blocks! They're, like, readable again. :)
Anyway, just to play around with the examples (which are pretty decent) was worth the intro price for me (I can expense it anyway). One big thing that does not yet exist is IB support. A few years back I switched to IB 100% (when possible) and so I'd much rather lay out my ui vs. code it all up. I've included a good Ars link below and in it Sansonetti says they're coming out with a DSL for easily laying out the ui. That will be interesting and it could push me over the edge for using this on a real project. Time will tell.
I kinda feel like I felt the first time I saw Rails. I would recommend anyone remotely interested just check out the Github demos.
http://arstechnica.com/business/news/2012/05/exclusive-build...
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.
This will let you, as a developer, try and learn to use RubyMotion before you actually buy a license.
A question for the developers - did you consider this option and reject it for some reason?
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.
As an Objective-C programmer myself, I was initially really turned off by this attitude from the JavaScript community: (Why do we need we need a LISP implementation in JS? It's already a functional language! Why do we need Objective-J? JS already kind of has classes!). Hilariously enough, the only language that was "accepted" by the JS community was the one that specifically promised that it wouldn't add any new features: CoffeeScript. I missed the Objective-C community precisely because I had always found it quite unreligious and practical: to each his own when it comes to development -- I hope that with its latest success it hasn't become more dogmatic and insular.
As I'm sure you've seen, even Objective-C is too slow for many things when developing for iOS - for instance, if you want to get halfway decent UITableView performance it's best to write a custom UIView where instead of laying out nested subviews, you drop into C and do all your layout in drawRect using only CoreGraphics API calls.
If you're attempting to do anything more complicated than hooking together pre-fab components, your performance is probably going to suck if your views are written in Ruby. And it's the silky smooth graphics people have come to expect that give iOS the reputation it's earned for slick UI.
It doesn't mean you shouldn't necessarily use a framework like this, but you don't get all that convenience for free. I've often felt that the reason Objective-C remains in use (aside from the fact that it's kept alive by Apple) is that it sits in a really practical middle ground between the bare metal performance of C and the convenience (and tradeoffs) of "nicer" languages. As I said above, though, this is just my default reaction, and I'd love to see this stuff in action if it's truly usable for a reasonable subset of use cases.
Also, Objective-C is not the slow bit in the example you described. There is a lot of logic overhead in laying out views in Cocoa. While it's true Objective-C (the language) may have some overhead, it's not much. And it's certainly not anything compared to laying out a complex view tree.
We already have -- and without great fanfare -- Lua, JavaScript, C# (MonoTouch), et al. This seems somehow different.
Douchebags are everywhere and it's sort of silly to paint an entire community with a broad brush. We're doing lots of good things, too, despite our own share of jerks.
Well… why not?
This is a relatively objective statement; the problem with ruby tends to be the crappy interpreter we're forced to suffer through - not the language itself. The Ruby language, in my biased opinion, as far as OO-functional languages go is pure awesome.
My initial reaction was: "A Ruby to Obj-C ABI compiler? Fuck no, what is wrong with you."
Upon learning it was the MacRuby dude: "Holy shit fuck yes".
I really don't want to ditch my entire development workflow to pick up Xcode, and Objective C, and miss out on all of the development libraries and vibrant community that I already have access to.
The problem with company led development environments is that they're tailored to the vendor's, and not the community's, needs. Development is rigid and low on innovation.
If this framework is half as good as it seems to be, within a month we'll see a dozen libraries that abstract all sorts of pain away from iOS development. Abstracting the pain away is something the Ruby community tends to do well.
I've gone from being totally uninterested in iOS development to being excited in what I can do inside UIWebviews. Naive, maybe, but it's probably significantly lowered the amount of investment I have to make into creating an iOS app.
Couldn't have said it better myself.
Anecdote: When ARC was first released, I decided to turn it on for a small project. The very first method I wrote blew up with a memory error. The reason? I used the NSFontMatrixAttribute of NSFontDescriptor. For some reason, ARC doesn't handle it correctly. I've never had such a thing happen in Ruby.
There is still a long way to go from where Objective-C is. It's moving in the right direction, but there's still a long road ahead of it. Ruby is closer to being there, though the lack of tool support (particularly autocomplete) makes it a much less compelling proposition than it would otherwise be.
Also, Ruby can be considerably easier than Objective-C to read because there is a lot less line noise. Objective-C's method names read very smoothly out loud, but they can also be visually overwhelming at times and make code sort of melt together into a wall of text. It's maybe a little bit easier to read Objective-C quickly when you're being very deliberate about it, but it's much easier to skim Ruby in my experience.
I probably won't be using this, and I think your criticism of Rubyists is kind of valid, but I think — for this particular project — you're dismissing it too readily.
Yeah, well, you know, that's just, like, your opinion, man.
Learning is hard, and doubly so when you're in your comfort zone. You can deride that and make it about a person's "toughness" as a programmer, or you can think about exactly how much time it takes to learn a language and its idioms, highlights, lowlights, problems, and features.
A person who's really good at C# or Java is not going to be really good at Obj-C without losing a significant amount of time. That's why these kinds of projects appear. There's only so much time in the day to learn a new language well. :)
As for your second paragraph, you can say that about any '-ists'. I've met java, python and .Net people who all love their respective languages and just want to code in that. To me, Rubyists aren't better or worse in that respect.
Interestingly, from my point of view, Obj-C made perfect sense to me when I realized that it was basically Ruby with C syntax. Given the heritage of Ruby and Obj-C, they come out as very similar languages, so I found it a breeze to pick up the other.
The hard part was learning the Cocoa (Touch) frameworks, but I'm not sure a Ruby API would have made that any easier. It's simply a massive amount of information to take in all at once.
For example, in using the RubyMotion beta, after I understood the UIView animation flow, I created a helper method using "yield" to do the actual animation. If I were working in Obj-C, it would've been a lot more work to do the equivalent (and I probably would've just copy-pasted existing code around instead).
Objective-C's heritage as a strict superset of C means that, ultimately, it's syntax is limited (why do you think all the new literal forms are prefixed with "@"). Ruby, on the other hand, excelles at constructing DSLs.
I think you'll find that this strength of Ruby will make RubyMotion a compelling solution for a wide range of tasks in iOS development. That said, CocoaPod support is built in, so you really can have the best of both worlds.
I've been using Ruby to create pleasant to use APIs around more complicated (native) APIs in both Java and .Net and it has always been a very big win in my situations.
I just bought a RubyMotion license and can see it going very far :)
Not to denigrate you or your statement, and yes Objective-C is not that hard to learn, but it comes down to speed.
If I've never programmed in Objective-C and if I'm experienced in Ruby my time from concept to live iPhone app can be FAR quicker by using the tools/language I'm already familiar with (regardless of which tools/language).
Remove the concept of learning a new language, a new IDE, and only require that I learn a new lib to work against and I'm FAR quicker.
Yes, there may be some limitations. But this is iterative development. Build something as solid and quick as possible, and give users the chance to play with it. If it works, and you need more flexibility, it's reasonable to spend the time on learning new tools/languages.
RubyMotion doesn't just slap on a Ruby syntax, its objects inherit from both Ruby and Objective-C classes with some mixed in Ruby modules.
The RubyMotion development environment is, in my opinion, an improvement over XCode. And of course, there's the REPL.
The "awkward hack" you mentioned is nothing. I don't particularly like the way he's implemented pointers to pointers, but that's also minor. The benefits, for me, easily outweigh the negatives.
Just for reference, yes I code in both Objective-C AND Ruby.
There are significant speed gains when using the tools/language you're most familiar with. I've seen this first hand with myself, and in others... It's not about "how easy it is to learn" it's about "how much time it takes."
You're mixing together two entirely different topics.
Actually, I can say the same regarding Java/Android API correlation.
Ruby skills: applicable across a very broad range of computing devices. Objective-C: not so much.
Sure if you're writing the unreal engine it's not going to be the best idea, but it should do fine for a Facebook/Three20 type app.
This is generally true of the Java community as well. There was a solid decade where there was a jSomethingOrOther for everything in development.
Sure, it's not hard to learn. But in my spare time, am I really going to work with a language I can't stand to make my iPhone app or am I just going to want to make a web app in Ruby? The latter sounds a lot more fun, but the former is obviously more efficient. The fact that we can now combine both? Holy shit.
This is a step in the right direction, a step toward getting immediate and interactive results when you code.
The piece that I find a tiny bit lacking is disconnect between what you futz with in the REPL and what is your source. By that I mean, all the manual tinkering in the REPL isn't saved anywhere, you have to copy and paste.
Emacs rectifies this sort of thing a little with swank and slime. Maybe there will be a mode for RubyMotion.
> 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.
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.
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.
"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"
http://lists.macosforge.org/pipermail/macruby-devel/2012-Apr...
1) http://arstechnica.com/business/news/2012/05/exclusive-build... (Review with code)
2) http://pragmaticstudio.com/screencasts/rubymotion (Screencast)
edit: also, please stop the heavy breathing into the mic. Driving me crazy!! :)
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... which was based on the JTGestureBasdeTableView: https://github.com/mystcolor/JTGestureBasedTableViewDemo
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?
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.
You're right though, there's no reason the UI wouldn't look identical as well.
For me, I prefer working in Ruby. Some people don't. But I think this will probably spurn me to get more serious about writing more iPhone apps, and it should open the door for a few more people who work on Ruby-based apps to write their own simple iPhone apps rather than paying a consultant to do it for them.
I can use Ruby's nice facilities for external processes (e.g., "x = `ls`" to get a directory listing or "system('do_something')") or simple regular expressions (i.e., "'string' =~ /my_regex/" and friends vs. NSRegularExpression's verbose syntax). I'm not forced to use Cocoa's verbose API if it has a nice Ruby wrapper (and if it doesn't have one, I can make one).
I can't express properly how awesome it is, really.
In practice, how big a problem is that?
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.
I bet they are working on it, though...
That may have changed tough because I dropped the xib as I didn't really needed it.
i.e. [obj method: param second: param2]; vs obj.method(param, second: param2) which is exactly two characters shorter in ruby.
And what would be the point of having something that looks like Objective-C?
Header files are so 70's.
I hope for the day when we have better and more type safe languages for system programming.
Most attempts so far, Modula-* family, Ada, Oberon and so on, failed to catch on, to my dismay.
Still it does not hurt to know some C.
If you have a good background in C than yes, using Objective-C is not so difficult.
This is a very exciting (and very positive) development, but at this moment in time I would still bite the bullet with Objective-C. I came to it with a background in PHP of all things and didn't struggle with picking it up in a few weeks.
I can't wait to see the things people do with it and with Ruby's metaprogramming.
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.
"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."
>RubyMotion is 100% compliant with Apple's App Store policies. Your code is compiled ahead-of-time, never interpreted, and you access the entire set of iOS public APIs. At the end, a RubyMotion app looks pretty much the same as an Objective-C app.
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.
Sometimes searching for an easy way out is a waste of time.
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.
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!
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"?
I find them really easy to follow.
"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."
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.
"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?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.
Bad programmers have a tendency to move from language to language, blaming their tools for their lack of skill.
This stuff is exciting.
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...
For a practical example of what this means, see the most recent sample code that was released for mobiruby: https://gist.github.com/2577620
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.
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.
So this should be compatible with cocos2d right?
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.
This looks worth it just to have an XCode-free toolchain.
(main)>> require 'date'
=> #<RuntimeError: #require is not supported in RubyMotion>
(main)>> Date
=> #<NameError: uninitialized constant Date>That being said, it could be great, I have no idea.