RubyMotion Goes 2.0 And Gets OSX Support, Templates and Plugins
blog.rubymotion.com
blog.rubymotion.com
I didn't know they were working on OSX support. But this is huge for me, back on GNU/Linux GUI programming using dynamic languages is easy. py-gtk/ruby-gnome2 bindings really work well and It is incredibly awesome that you can build small utils for yourself in a afternoon using py-gtk/ruby-gnome2. Ability to do the same for OSX is exciting!
* Obj-C, from the very start, was implemented as a strict superset of C. This means that every valid bit of C code must also be valid Obj-C. This places some rather sever limitations on the Obj-C syntax. Ruby does not have this limitation, and neither does RubyMotion. So one reason you might use RubyMotion is to get a cleaner syntax that does the same thing as Obj-C.
* The Obj-C runtime is very dynamic. You can create classes on the fly, add methods to them at runtime, move methods around between objects, and create methods dynamically. The Obj-C language makes it nearly impossible to take advantage of any of these features of the Obj-C runtime. So another reason you might use RubyMotion is to get the most out of the Obj-C runtime.
Edit: I obv. didn't write your parent comment. What I meant was that I'm sure others in my position, having read your parent, would appreciate more elaboration from you as well. :)
Here's how to create a property on the fly (great for categories)
@dynamic progressView;
- (void)setProgressView:(ACProgressView )progressView { objc_setAssociatedObject(self, ACProgressViewKey, progressView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); }
- (ACProgressView )progressView { return objc_getAssociatedObject(self, ACProgressViewKey); }
NSObject obj = [NSObject init];
giveObjectAProperty(obj, @"progressView");
obj.progressView = [NSNumber 42];
Writing giveObjectAProperty may not be "nearly impossible" but it sure isn't easy.And of course the parent is talking about methods, not properties, but...same argument.
Here's how you'd make that class on the fly:
Class mySubclass = objc_allocateClassPair([NSObject class], "MySubclass", 0);
Here's how you'd add a description method to a newly created class: static NSString *Description(id self, SEL _cmd){
return [NSString stringWithFormat: @"<%@ %p: foo=%@>",[self class], self, [self foo]];
}
// add Description to mySubclass
// grab NSObject's description signature so we can borrow it
Method description = class_getInstanceMethod([NSObject class],
@selector(description));
const char *types = method_getTypeEncoding(description);
// now add
class_addMethod(mySubclass, @selector(description), (IMP)Description, types);
And your iVars: class_addIvar(mySubclass, "foo", sizeof(id), rint(log2(sizeof(id))), @encode(id)); klass = Object.const_set "MySubclass", Class.new(Object)
klass.send(:attr_accessor, :foo)
klass.send(:define_method, "description") {
"<#{self.class}: foo=#{self.foo}>"
}[1]: https://github.com/mikeash/MAObjCRuntime [2]: https://github.com/mikeash/MACollectionUtilities
But the real payoff is threefold:
1) You can use and write very ruby-ish wrappers for things. A great example is teacup, which lets you essentially write stylesheets for your UIViews (and I guess now NSViews).
2) Working with collections like arrays and hashes is MUCH more convenient. You can spend a good part of your time doing just that.
3) Command-line toolchain. It's not for everyone, of course, but for those who work better like that, it's a revolution.
Right now it's pretty wild west. There's no obvious winner in terms of libraries for the data layer, for example. So taking on an RM project right now either means rolling up your sleeves and hacking on the infrastructure, or just living with raw Cocoa, without benefit of autocomplete. Give it another 6-12 months and I think you'll see a very strong contender.
> That means, no writing everything twice (header files,
> type declarations)
Your header files can be practically empty if you don't need to show something to outside. Just put your @property'ies into class extension. Even @synthesize no longer needed (most of the time, there are exceptions).
> Working with collections like arrays and hashes is MUCH
> more convenient. You can spend a good part of your time
> doing just that.
With latest versions of XCode it is possible to use foo[5] instead of [foo objectAtIndex:5] and foo[@"bar"] instead of [foo objectForKey:@"bar"];
There are also array and dictionary literals @[…], @{…} and you can also just type @1 to get NSNumber from primitive.Cocoa is a fantastic system to build on top of. NSDate is MILES better than the Ruby time stuff, for example. NS/UI solid core plus Ruby's flexible syntax and culture of sensible defaults is a marriage made in heaven.
Well, there's a solid argument to be made in favor of limiting how much internals are exposed to other objects. I personally like keeping my headers as minimal as possible.
As for readability. Ruby is getting there but currently:
- (void)employersWithCarrierID:(uint)carrierID withMaxReturnCount:(uint)count;
[self employersWithCarrierID:123 withMaxReturnCount:10];
is a lot more readable and verbose than def employers (id, count)
employer 123 10`employer carrier_id: 123, max_return_count: 10` is very much valid ruby.
[1]: https://github.com/pandamonia/BlocksKit [2]: http://pandamonia.github.io/BlocksKit/Documentation/Categori...
RubyCocoa was actually a wrapper, but was very slow. MacRuby's innovation was that it was a Ruby implementation in Obj-C, but it relied on GC and was Mac OS X only. RubyMotion ditched the need for the GC and supports iOS and now Mac OS X.
Hopefully the RubyMotion support will be better!
Anyone from Apple, or anyone that gained the sense in events like WWDC, care to share?
Their major remaining rule is that you can't build environments that download code from the internet and run it. (Except for Javascript, and you have to use JavaScriptCore (Apple-supplied) for that.)
Would love to play with this but am fairly invested in a big obj-c thing right now.
I translated the models into Ruby, and pulled those out of the xcode lib. Eventually the entire codebase was converted (except the nibs).
https://lists.macosforge.org/pipermail/macruby-devel/2012-Ap...
It's quite a sad day to think that Apple invested on MacRuby and kept it open source... and RubyMotion chose another route even for OS X dev.
Give me a break. The guy's made something amazing. Good on him for charging for it, making a success of it, so much so that we now have a version 2.0. This would never have come from some lousy half-hearted Apple mailing list.
I am happy to pay for this product, and I do not blame him for keeping it proprietary. I just don't see what your point is. It seems like you just want something for nothing and are dressing that up in some unlikely open-source clothes.
Charging for software is not a crime. The point is that he lied to the open source community about his intentions.
Laurent frankly is underpricing his wonderful tools, and has to support himself and all those folks he's hired.
Time is finite, and no human can do all the things they'd like to do.
Modifying RubyMotion to have the right hooks for the OS X apis etc is likely much simpler than fixing up MacRuby architecturally.
Point being, people have finite time, they can't do all the things they want to. Either be nice or give him a time turning / time travel device
f6908b2 - 2011-04-28 21:50:28 -0700 fixed a stupid bug in the Xcode4 template (Matt Aimonetti)
I agree, it’s too bad that people can’t just work for free as much as they would like on the stuff they love.
Now it is true that Laurent himself has not touched the repo since that email you linked to, but you know just as well as me that Watson has been doing maintenance work on MacRuby while on the payroll of RubyMotion (HipByte). His latest commit was 15 days ago and here’s a generalised diff of all the work done since the email: https://github.com/MacRuby/MacRuby/compare/94c90b351c18ce1f5....
This is what people with limited time resources do, they delegate.
To conclude, when you’re out to paint someone black, you really should be more specific. As it stands, there are no lies in that email, which means that you are the one that is not telling the truth. I’m not sure why you want to spread FUD, but it’s quite obvious and really does not make you look professional.
PS: Whatever Apple chose or chooses to do has absolutely no relevancy to this at all. The moment they released it as Open-Source, they effectively said that people can do what they want as long as they follow the license.
This is exactly what RubyMotion just released and I'm saddened that it was not contributed back as promised.
It's as simple as that.
What about the folks that bought into the book and MacRuby, thinking that it was a viable project, and then see you, one of the (few) main contributors abandon it -- and long before today's release of RubyMotion.
Shell out the $200 for the hard work they put into it and get over your entitlement complex.
"But you PROMISED!"
>Apple invested in MacRuby? What a joke!
Yes, it did. Back in the day, MacRuby started by Apple employees and initial development was paid by Apple.
>This project was almost singlehandedly held by one person.
Which is beside the point.
>I know for a fact that Apple doesn't give a fuck about MacRuby
You don't say! That has been the case several years now, since Apple stopped supporting the project. Everybody in the MacRuby community knows this.
>don't fool yourself about that.
Thank you, Captain Informed.
MacRuby is slow and clunky. Fact. This is a big improvement performance wise.
Do I mind paying for that improvement? Hell no. MacRuby development has pretty much halted once it lost Apple Support. I don't mind paying for something that will be maintained and improved upon.
Also, I wouldn't mind paying for RubyMotion as long as I'm assured the project will go forward.
Unfortunately MacRuby lost momentum when Apple decided to not support the project anymore.
Why? Because now some of my customers are going to seriously think about using Ruby for Mac OS X apps, because they know someone is making profit while supporting this, so they feel they can rely on this.
I much prefer this to the fate of IronRuby (or to some extent, MacRuby).
Remember what you wrote one year ago [1] ?
Using RubyMotion for a professional product represents
a significant business risk, which is exactly the same
as using proprietary technology from any vendor.
It turns out the opposite is coming to reality :p[1] http://merbist.com/2012/05/04/macruby-on-ios-rubymotion-revi...