Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could MacRuby / HotCocoa supplant the need to know Objective-C?

I just discovered MacRuby / HotCocoa and really like the sound of what they're doing.

I had essentially discounted the prospect of making Cocoa GUI applications myself because I have an aversion to spending time & effort learning yet another C-based language, Objective-C. I'm not saying it's bad, just not for me.

Is it the case now, or in the probable future, that one will be able to make Cocoa GUI applications of substantial and first-class nature with MacRuby / HotCocoa alone while ignoring Objective-C completely?

(Edit: Desktop Mac, not iPhone)

like image 988
xyz Avatar asked Apr 19 '10 00:04

xyz


4 Answers

"It is the goal of MacRuby to enable the creation of full-fledged Mac OS X applications which do not sacrifice performance in order to enjoy the benefits of using Ruby." - the MacRuby README

MacRuby isn't a 'translation layer' as Rob says. It's Ruby on the same object system that Cocoa is using. You can certainly build "first-class" applications with it, and also accomplish things that are inconvenient with Objective-C.

Be careful not to confuse MacRuby with RubyCocoa. Apple did not 'pull all the templates' for MacRuby, because they've never shipped by default.

Furthermore, LLVM's integration with Apple's platforms grows with each release. The next release of XCode will rely on LLVM for advanced code-completion, checking, and compilation. If Apple is deemphasizing anything it's the GCC.

One might also note that MacRuby has similar limitations in API coverage as Objective-C does: for instance, creating authenticated apps or accessing the keychain requires wrapper classes for both languages.

like image 73
arbales Avatar answered Oct 16 '22 23:10

arbales


It will be extremely difficult to build first-class apps through a translation layer. It's hard enough to get the performance and behavior you need natively. I'm impressed with MacRuby's approach, and particularly impressed that they are able to manage things like Core Animation (a key piece of first-class Mac apps) and Core Data (which is tough stuff). I'm really impressed with their use of more idiomatic Ruby rather than the ugliness of RubyCocoa. But there are reasons that Apple has "deemphasized" (as they've called it) their multi-language dalliances in Java, Ruby, Python, etc. It's hard enough to write this stuff in one language. It's hard enough to get it right when you're not going through a semi-supported translation layer. In practice, you still have to learn the ObjC syntax to deal with the documentation and all the existing code. In practice, you still have to learn the ObjC patterns to develop decent Mac apps.

MacRuby is interesting. Even as a seasoned ObjC programmer, I might consider HotCocoa for hacking up prototypes and trying out interfaces. But it's not the kind of thing I'd use to build, as you say, "Cocoa GUI applications of substantial and first-class nature."

As developers, part of our job is to have a bag of tools. Like a good carpenter has several different hammers, plus pry bars, nail sets, several kinds of square and a dozen other tools, a programmer should be comfortable with a variety of languages, programming paradigms, platforms and environments. She then should be able to choose the correct tools for the job and employ them effectively. In the case of Mac programming, the correct tools for the job include Xcode, IB, ObjC and Cocoa. Avoiding them is like a carpenter avoiding a framing hammer and speed square. They're just part of the job.

like image 36
Rob Napier Avatar answered Oct 16 '22 22:10

Rob Napier


I did spend some time on RubyCocoa, but what made me look into Obj-C was that in the end all documentation of Cocoa and other frameworks was written in Obj-C syntax. In it self Obj-C is not a very big language IMO, and should not take to long to pick up at all, if you have some experience in some other C based language and OOP. What is quite large is the frame works though, Cocoa etc. and at least with rubyCocoa you would still have to learn the frameworks. Besides this, I have a hard time believing that a scripting language like Ruby could ever give the same performance as a compiled C language.

like image 1
Fred Avatar answered Oct 16 '22 23:10

Fred


It's possible to write a Ruby app using Apple's Frameworks that looks just like a native ObjC app.

But don't take my word for it, look here for examples of such apps. They look and perform native enough that it isn't possible for a casual user to distinguish between native Ruby and native ObjC.

like image 1
sal Avatar answered Oct 17 '22 00:10

sal