[MacRuby-devel] book idea - "making it look like Ruby"

Mark Rada mrada at marketcircle.com
Fri Feb 4 13:27:59 PST 2011


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 at 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 at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list