5 ms·
nice, but where is the advantage over just using objc? the hard part of coding for iOS isn't objc, it's learning how to use all the API's.
by tobiasbischoff 14y ago
nice, but where is the advantage over just using objc? the hard part of coding for iOS isn't objc, it's learning how to use all the API's.
- jeremymcanally 14y agoI write code in both Ruby and Objective C pretty regularly, but man oh man is my Ruby code SO MUCH shorter and cleaner in a lot of respects. A lot of the Objective-C API's are just terribly terribly verbose. My favorite one to whine about is NSTask; it shouldn't take me 10 lines of code to spawn a simple external process. :P 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.
- cageface 14y agoBut you're going to be coding to those same Apis in ruby too, just with a lightly different syntax.
- jeremymcanally 14y agoNo, actually. 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).
- cageface 14y agoThis: https://github.com/HipByte/RubyMotionSamples/blob/master/GestureTable/app/view_controller.rb https://github.com/HipByte/RubyMotionSamples/blob/master/Ges... Is what 95% of the code in your app is going to look like and I don't really see what it's buying you. You're also throwing away all the type checking you'd get on essentially the same code in Obj-C. I really like Ruby but I don't intend to use it for iOS apps.
- hlidotbe 14y agoHaving been part of the private beta I can tell you that it's a huge time saver. Objective-C is nice be ruby is much more expressive, you can use the same API with much less code, you can skip XCode altogether and use your favorite editor, ... I can't express properly how awesome it is, really.
- protomyth 14y agoThe call syntax is still painful compared to straight Objective-C as it actually uses more characters and is not as clean. I really wish he had come up with something that resembled Objective-C better.
- hlidotbe 14y agoI may have missed something but API calls looks like a regular Ruby call with a hash and since all [] are dropped it's systematically shorter (not even counting the fact that you don't have .h/.m, declaration/implementation, it's not just a matter of API calls). 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?
- protomyth 14y agoI was looking at the example and their are a fair number of commas. If you pass 3 selectors it is longer. UIColor.colorWithRed(red/100.0, green:green/100.0, blue:blue/100.0, alpha:1.0) vs [UIColor colorWithRed:red/100.0 green:green/100.0 blue:blue/100.0 alpha:1.0]; >And what would be the point of having something that looks like Objective-C? Because the name of the function is not colorWithRed(), it is colorWithRed:blue:green:alpha:.
- deleted 14y ago[deleted]
- tpz 14y agoSeeing as we're splitting hairs... :) In the Ruby version I wouldn't use that selector with any parens. The resulting line would be one character longer than the ObjC version but use the Shift key one less time and would avoid two pinky trips out to the square brackets. (unless I am miscounting) All other things being equal between the two options, and of course they aren't but let's just keep splitting hairs for a moment, it sounds like a typing win for the Ruby option. Readability is of course in the eye of the beholder.
- octopus 14y agoIt depends, if your background is in dynamic languages like Perl, Ruby, Python than using Ruby for iOS makes a lot of sense. On the plus side Ruby is better for programmer productivity. If you have a good background in C than yes, using Objective-C is not so difficult.
- FuzzyDunlop 14y agoI concur with the other posters who say Objective-C itself is not the barrier, the API is. Such is the design and verbosity of the API (which is great for self-documentation and talking about, less so for typing), it'd be an absolute nightmare to work with without the extensive auto-complete Xcode offers. 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.
- pjmlp 14y agoI agree, but many young developers have C phobia and somehow seem not to be able to grasp C based languages.
- andybak 14y agoOr they've been spoiled by certain language features and it seems unbearable to go backwards.
- 286c8cb04bda 14y agoWhat language features does Ruby have that Objective-C lacks? It's a bit more succinct, perhaps, but when you're calling out to Cocoa all the time, that succinctness is going to get thrown out the window.
- jballanc 14y agoRuby has "yield" which, while possible to replicate in Obj-C, it's not nearly as nice. Also, Ruby can yield arguments, and the block being yielded to is free to ignore those arguments. That's the sort of flexibility that can make Ruby so much more enjoyable to work with in high-level code.
- 286c8cb04bda 14y agoThat's a great example, thanks! I did some looking, and I found a few[1] examples[2] of coroutines in Objective-C, though none of them seemed fully fleshed-out. Even if they were, none were, as you say, nearly as nice as "yield". [1]: http://cocoadev.com/wiki/CSCoroutineTest http://cocoadev.com/wiki/CSCoroutineTest [2]: https://gist.github.com/1033477 https://gist.github.com/1033477
- deleted 14y ago[deleted]
- pjmlp 14y agoPersonally I find great that we have a native Ruby compiler, even if it means a static language with Ruby like syntax in the end. 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.