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.
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).
def animate
UIView.begin_animation
yield
UIView.commit_animation
end
animate do
# Do something
end
and: void animate(void (^block)(void))
{
[UIView beginAnimation];
block();
[UIView commitAnimation];
}
animate(^ {
// Do something
});
Which to my eye are pretty much exactly the same. In fact, UIView already provides a similar method built into the API.Anyway, I don't want to diminish what you've accomplished. It's an awesome achievement regardless of the language you choose.
Yeah, it's actually much, much simpler to do it in Objective-C in this case.
[UIView animateWithDuration:0.5f animations:^{
// Do something
}];UIView.animateWithDuration(0.5, animations:lambda { //do something })
in RubyMotion. Basically the same.
def animate(*args)
UIView.begin_animation
yield(*args)
UIView.commit_animation
end
animate(myButton, &buttonAnimateBlockFromSomewhereElse)
animate(myView, myOtherView, &genericAnimateBlockFromSomewhereElseWithTwoArgs)
animate do
# Do something locally ignoring args
end
And, yes, you can do the same thing with Obj-C and some creative casts...but it's nicer in RubyMotion! (ymmv) [UIView animateWithDuration:1.0f
animations:^{
self.view.alpha=0.0f;
}];
Not so hard.I think I'll try and write up a demo app to explain what I mean...
I think you are over thinking things.
void animate(void (^block)(va_list), ...)
{
va_list args;
va_start(args, block);
block(args);
va_end(args);
}
void (^first)(va_list) = ^(va_list args) {
NSLog(@"%@", va_arg(args, id));
};
void (^second)(va_list) = ^(va_list args) {
NSLog(@"%@", va_arg(args, id));
NSLog(@"%@", va_arg(args, id));
};
animate(first, @"Hello World");
animate(second, @"Hello", [[NSNumber alloc] initWithInt:10]);
I would like to see the real-world code too. The frameworks in question revolve around Obj-C-isms, so to see something that completely deviates from those patterns will be interesting.