views:

329

answers:

6

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)

A: 

MacRuby is somebody's pet project. If that somebody puts together a compiler that spews out native binaries from Ruby code, then it's a distinct possibility that it may gain some ground someday. If they just keep doing what they're doing now, then no, it's going to remain a niche product until that somebody either quits or gets fired and has their work buried alongside the Java Cocoa bindings and WebObjects.

Azeem.Butt
MacRuby is backed by Apple and already has a compiler.
mckeed
@mckeed "Backed by Apple" may be a strong statement. Apple definitely stuck their toe in the water in Leopard, but they've been backpedalling ever since. 10.6 pulled all the Ruby templates and MacRuby acts more like a tolerated side project than something that has Apple's full backing. It's even licensed under GPL rather than APSL. Why do you say there's a compiler? MacRuby dumps all your .rb files into Resources and interprets them at run time. Is there a compiler you know of?
Rob Napier
I don't know how much support there is for it within Apple, but the credits on the website say "project by Apple Inc." It isn't at version 1 yet, so you can't expect Apple to advertise it. The ruby templates in XCode were from before MacRuby. The compiler is new in 0.5: "Thanks to LLVM, MacRuby is able to transform the Ruby AST from the parser directly into highly optimized machine code. MacRuby supports both JIT and AOT compilation." (from http://www.macruby.org/blog/2009/10/07/macruby05b1.html)
mckeed
@mckeed Thanks for the information on the LLVM compiler. That's definitely worth digging into. It doesn't change my view of the viability of this for large-scale projects, but it's a very interesting development, and really drives home how revolutionary LLVM can be.
Rob Napier
Apple backed the Java bindings, too. How far did those get again?
Azeem.Butt
MacRuby can spew out native binaries from ruby code already using their macrubyc compiler :-)
Orion Edwards
+1  A: 

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.

Fred
rubyCocoa != macruby
ergosys
+3  A: 

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.

Rob Napier
It is interesting to me to note that (with tongue planted firmly in cheek) whatever time is saved by writing an application in a very-high-level language is often spent later in trying to overcome the leaky abstractions in that high-level language. Whether it's the Global Interpreter Lock in Python or the (insert-achilles-heel-for-Ruby-here) of Ruby. I don't know enough about Ruby, but I doubt it's the only very-high-level dynamic (interpreted) language without limitations and areas where it could improve. Often the weakest area in such an application is the binding to the GUI.
Warren P
frou
+1  A: 

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.

sal
You hit the nail on the head when you distinguished what "a casual user" will notice vs. frou's question of "first-class" Mac apps. Ten minor apps (most of which are stagnant or dead) don't demonstrate a framework's ability to deliver major applications. ObjC is really the lowest of the hurdles in making excellent Mac apps. Deeply "getting" the Mac experience and how apps are supposed to work and integrate is the true hurdle. It's the difference between an app that "looks" like a Mac app and one that *acts* like a Mac app.
Rob Napier
RubyCocoa is not MacRuby.
Matt Garrison
A: 

Hey, I tried it, and give up, because after seeing it's all just replacement for ObjC, ObjC suddenly seemed to me as a fantastic language. I learn ObjC, and I like it.

Vojto
+3  A: 

"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. MacRuby is pre-release software, and Apple certainly isn't 'deemphasizing' it. I'd ask those that say otherwise to throughly research the topic, and ensure that they're making accurate statements.

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. It's safe to say a huge-scale application on the Mac will require the use of pieces of multiple languages for years to come, but MacRuby has a strong future and a usable, capable present. I'd encourage you to search GitHub for awesome MacRuby wrappers.

All the evidence currently suggests that you and I both can look forward to building apps of all kinds with MacRuby across Apple's platforms.

arbales
It's a laudable goal, and I hope someday it is successful. Can you point to anything that demonstrates that it exists *today* in a form that could do what the OP requested? We were discussing 0.5 at the time. Even in 0.6, I see things like "experimental support for debugging" and major rewrites in the guts. Yes, this might some day do everything it hopes, but my opinion stands that *today* it is not a language I would write "first-class" Mac apps in. It's impressive; but it still has a long way to go, and I believe will always be playing slow catch-up to ObjC Cocoa.
Rob Napier
Well, first: the question is in the conditional. It did not ask, "Has MacRuby supplanted Objective-C" but instead, "Could ... in the probable future." Secondly, MacRuby already provides tools for debugging code, although not in the sense I think you mean. And, the point isn't to "catch up to ObjC+Cocoa," but to provide an alternative to it. Finally a 'first-class' app is defined by excellent UI and functionality, both of which are achievable with MacRuby, today.
arbales
You might also look at this: http://github.com/davebaldwin/Ruby-Sketch. It's an example of a simple graphics app in MacRuby. So if you consider OmniGraffle, a 'first-class' app, it looks pretty possible. That being said, OmniGraffle ain't great.
arbales
I welcome your optimism :-)
frou