8

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)

xyz
  • 27,223
  • 29
  • 105
  • 125
  • 1
    From the MacRuby author's page: "Experimentation MacRuby provides a convenient way to experiment with Ruby 1.9 on Mac OS X (e.g., trying out new syntax). At the same time, MacRuby provides a convenient way to experiment with the Mac OS X frameworks. For example, macirb allows interactive access to both Ruby and Mac OS X libraries. So, for example, a Cocoa programmer might find MacRuby to be a congenial prototyping environment, even if the ultimate product needs to be written strictly in Objective-C." In short, the author doesn't see this as the panacea that you're envisioning. – Warren P Apr 19 '10 at 15:01

6 Answers6

13

"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.

arbales
  • 5,466
  • 4
  • 33
  • 40
  • 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 Aug 02 '10 at 14:26
  • 1
    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 Aug 03 '10 at 04:44
  • 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 Aug 03 '10 at 18:16
4

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
  • 286,113
  • 34
  • 456
  • 610
  • 1
    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 Apr 19 '10 at 14:55
  • Rob, thanks for your input in here. Thinking about the original question again, saying "substantial and first-class" gave too grand an expectation of what I personally would do. "Perfect Mac look & feel" instead, perhaps! – xyz Sep 06 '10 at 11:58
  • 1
    I'm not sure you'll find the problems you speak of with MacRuby. Ruby is an ideal environment to work with objects: things like open classes and blocks bring a natural feel to their cocoa counterparts. Make an HTTP request with MacRuby, and you'll realize how awesome it is. – arbales Nov 17 '10 at 19:35
1

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
  • 449
  • 1
  • 5
  • 13
1

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
  • 23,373
  • 15
  • 66
  • 85
  • 1
    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 Apr 19 '10 at 03:28
0

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
  • 6,901
  • 4
  • 27
  • 33
-1

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
  • 5,855
  • 1
  • 26
  • 22
  • 2
    @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 Apr 19 '10 at 03:39
  • 3
    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 Apr 19 '10 at 04:48
  • @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 Apr 19 '10 at 14:44
  • 1
    Apple backed the Java bindings, too. How far did those get again? – Azeem.Butt Apr 19 '10 at 18:55
  • 2
    MacRuby can spew out native binaries from ruby code already using their macrubyc compiler :-) – Orion Edwards May 03 '10 at 03:18
  • Now where Apple kicked the garbage collector and replaced it with ARC the use of MacRuby becomes uncertain. Lesson to learn it you haven't now - never trust a pet project or apple. – Lothar Jun 21 '13 at 16:45