MacKuba

🍎 Kuba Suder's blog on Mac & iOS development

To Cocoa or not to Cocoa, that is the question...

Categories: Cocoa, Python, Ruby/Rails Comments: 0 comments

It seems that starting a blog was not the only stupid idea I had recently. I’m having more of those… For example, now I’m thinking about learning some Cocoa and writing some applications for the Mac :) I’ve been planning for some time to write something in Qt when I used Linux, but now it seems that although Qt has the advantage of being multi-platform, so I could write something that could be used on Windows, Linux and Mac, the disadvantage is that only a subset of Cocoa widgets are available in Qt; I couldn’t use some of the things I saw in native Mac applications, and because of that, my applications would be less “macish”…

So I can write something in Qt, and make it available on 3 platforms (and for about 10× more people), but with the GUI slightly less pretty; or learn a new framework, write only for Mac, make it look as great as other Mac programs, but be limited only to one platform. Difficult choice… And if Cocoa, then what language? There’s Objective C, which is totally weird and exotic, probably less convenient than Python or Ruby, but is the recommended language and probably runs faster. There’s also Python; and there’s Ruby, in two variants – RubyCocoa, more “classic”, and MacRuby, based on Ruby 1.9, with extended syntax, apparently running much faster than normal Ruby. Here’s how the syntax compares:

// ObjC
[person setFirstName:first lastName:last];
# PyObjC
person.setFirstName_lastName_(first, last)
# RubyCocoa
person.setFirstName_lastName_(first, last)
person.setFirstName_lastName(first, last)
person.setFirstName(first, :lastName, last)
# MacRuby
person.setFirstName(first, lastName: last) # yes, it's not a typo
person.setFirstName first, :lastName => last

I’m thinking that MacRuby could be the best option…


Leave a comment

*

*
This will only be used to display your Gravatar image.

*

What class method do you use in Ruby to define a read-only property?

*