One of my concerns with both MacRuby and JRuby is that the resulting code doesn't look much like Ruby. As Mark Twain put it: ... If man could be crossed with the cat it would improve man, but it would deteriorate the cat. While skimming "Using JRuby", I saw a few suggestions about ways to alias Java calls (etc) to make the code look more like Ruby. Unfortunately, there wasn't as much of this as I would have liked and it wasn't in a single chapter, for easy reference. Regardless of HotCocoa's failings, it certainly helps to make MacRuby look more like Ruby than Objective-C. Even if HC isn't covered, per se, I'd like to see some coverage of these sorts of style issues. -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation
On 2011-02-04, at 01:26 , Rich Morin wrote:
One of my concerns with both MacRuby and JRuby is that the resulting code doesn't look much like Ruby.
I'm sure the situation in JRuby land is worse, but generally, using Cocoa stuff from MacRuby feels enough like ruby, save for the HorridCamelCase, but I've gotten used to that. One other issue that annoys me tremendously is passing NSError pointers. I've created this generic wrapper to raise ruby exceptions instead: https://github.com/kch/aliastool/blob/master/src/raisins.rb E.g.: raisingNSError { |e| NSURL.bookmarkDataWithContentsOfURL(alias_url, error:e) } I'd be curious to see other snippets that make MacRuby look more like Ruby, but mostly… I don't think there's an easy way out of this. Whenever someone gets into a new language, they'll first try to shoehorn it into the language they're familiar with. Java coders will write ruby that looks like Java. ObjC coders will write code that looks like ObjC. And especially, Noob coders will write n00b code. Even python people coming to ruby wtite like it is verbosefest. Most post-Ruby-on-Rails ruby code I've seen is a crazy mess of pointless assignments and neverending if-then-elsery. /rant Eventually people learn, but they won't go after a book until they realize there's a problem with the way they write code.
I am a newbie when it comes to using Cocoa (and by no means a Ruby expert), so I've only seen a few patterns in Cocoa stuff. A pattern I tried the other day was to use a procs where Cocoa wants a callback object/method for delegation. This is as close to using blocks as I can get when they don't have versions of the method that takes a block. It seems to be broken right now (logged a bug the other day). Mark Rada mrada@marketcircle.com On 2011-02-04, at 3:57 PM, Caio Chassot wrote:
On 2011-02-04, at 01:26 , Rich Morin wrote:
One of my concerns with both MacRuby and JRuby is that the resulting code doesn't look much like Ruby.
I'm sure the situation in JRuby land is worse, but generally, using Cocoa stuff from MacRuby feels enough like ruby, save for the HorridCamelCase, but I've gotten used to that.
One other issue that annoys me tremendously is passing NSError pointers. I've created this generic wrapper to raise ruby exceptions instead:
https://github.com/kch/aliastool/blob/master/src/raisins.rb
E.g.:
raisingNSError { |e| NSURL.bookmarkDataWithContentsOfURL(alias_url, error:e) }
I'd be curious to see other snippets that make MacRuby look more like Ruby, but mostly…
I don't think there's an easy way out of this. Whenever someone gets into a new language, they'll first try to shoehorn it into the language they're familiar with. Java coders will write ruby that looks like Java. ObjC coders will write code that looks like ObjC. And especially, Noob coders will write n00b code. Even python people coming to ruby wtite like it is verbosefest. Most post-Ruby-on-Rails ruby code I've seen is a crazy mess of pointless assignments and neverending if-then-elsery. /rant
Eventually people learn, but they won't go after a book until they realize there's a problem with the way they write code.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
At 6:57 PM -0200 2/4/11, Caio Chassot wrote:
On 2011-02-04, at 01:26 , Rich Morin wrote: I'm sure the situation in JRuby land is worse, but generally, using Cocoa stuff from MacRuby feels enough like ruby, save for the HorridCamelCase, but I've gotten used to that.
Interestingly, JRuby does quite a bit of work to let folks use snake_case, instead of CamelCase. -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation
participants (3)
-
Caio Chassot
-
Mark Rada
-
Rich Morin