4 ms·
> 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
by flatline3 14y ago
> 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 14y agoI 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 14y ago> 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.
- chc 14y agoRisky, error-prone and not correct? If you're going to throw out that kind of slander, you ought to back it up or it's just FUD. People used to say the same thing about Cocoa's "black magic" like the responder chain, undo support and Interface Builder. I didn't buy it from them then, and I don't buy this now.