Is is possible to debug a MacRuby Cocoa app?
Hello, and thank you very much to the developers of MacRuby. It's an amazing technology and I hope to see it continue to grow. I've managed to figure out, after an hour or two of wasted time, that although MacRuby now includes a debugger, that debugger can't be used to debug a MacRuby Cocoa app. Not only through XCode, but at all. Is that correct? The release notes proudly announce that MacRuby now includes a debugger but they neglect to mention how to use it. After some research I eventually discovered that there is no way to use the debugger to debug a Cocoa app. If that's true, then lack of a debugger eliminates any benefit that using Ruby could bring to the Cocoa experience. Objective C syntax is truly nasty, but if there is no debugger available for Cocoa apps written with MacRuby then it just doesn't make sense to use Ruby to make a Cocoa app. Especially with Objective C 2.0's simplified syntax and garbage collection. "You don't need a debugger for Ruby code", is simply not a realistic solution. TDD and BDD tools for desktop Cocoa apps are still inadequate, and even with TDD you often still need a debugger. MacRuby isn't going to go very far if developers are forced to revert to printf debugging to build Cocoa apps. I don't mind if the debugger doesn't have slick XCode integration like GDB. But there needs to be SOME way to debug a Cocoa app or else the sensible path for developer productivity on the Mac will be Objective C 2.0 instead of MacRuby. Sacrificing any hope of using a debugger to gain relatively minor syntactic improvements is not a tradeoff that makes any sense. I don't intend to disparage MacRuby, I just want to share my perspective as both a professional Rubyist and a professional Cocoa developer. MacRuby is an amazing technology, but to gain traction as a realistic way to build Cocoa apps it will really need a debugger that works with Cocoa apps. -- Ryan
On Nov 21, 2010, at 3:49 PM, Ryan Porter wrote:
I've managed to figure out, after an hour or two of wasted time, that although MacRuby now includes a debugger, that debugger can't be used to debug a MacRuby Cocoa app. Not only through XCode, but at all. Is that correct? The release notes proudly announce that MacRuby now includes a debugger but they neglect to mention how to use it. After some research I eventually discovered that there is no way to use the debugger to debug a Cocoa app.
I think this is not a case of deliberate (or unknowing) omission so much as a little over-enthusiastic "marketing" of a command-line-only debugging feature that itself is just barely out of alpha-quality status. Calling what is currently there an "experimental debugger" would probably be more accurate, and set expectations more correctly, but you can't really blame the developers for an abundance of enthusiasm for something which is, at least, the start of something in this area. It's kind of an ugly truth about most interpreted languages, from Tcl to Python to Ruby, that the integrated debugging support basically sucks and is rarely designed into the default implementations of said languages. Proponents of those languages generally claim that it's so easy to sprinkle debugging "printfs" into their code, emit log messages, etc, that they don't *need* a debugger, whereas I suspect that the kind of debugging experience you're looking for probably involves a graphical IDE with debugging breakpoints set in the source browser/editor in addition to views for watched variables, calling context information, and all the other fun stuff you'd expect from an interpreted language debugger. Sorry, but such a thing has simply not been implemented yet! - Jordan
Thank you very much for the replies. I completely understand now about the state of the debugger, and I'm interested in alpha testing whatever debugger is available. I'm not afraid of experimental, bleeding-edge code and tweaking things out. Clicking on lines in XCode to set breakpoints like a VB coder is NOT what I was imagining at all. I use Ruby a lot, and one of the things that I love the most about dynamic runtime environments is the ability to stop code while it's executing, and then interact with objects using the same language that I use in the code files. The simple ability to insert a "debugger" statement to trigger ruby-debug to stop and give me a prompt where I can type "User.last.inspect" is a very powerful thing. Far more powerful than GDB could ever hope to be. I understand that there won't be integration with XCode for a long time, and that if/when there is XCode debugger integration that it won't necessarily look or feel like using GDB in XCode. Given my hopes/expectations, is there any way to set up a Cocoa app so that it runs code in macrubyd intead of macruby? So that I can set a breakpoint to stop it and look around? I definitely don't care whether I have to set the breakpoint from the command line or even from hard-coding the breakpoint in my Cocoa app's main.m main() function or whatever. If anybody could provide any pointers on any way to use macrubyd to debug a Cocoa app then I would really appreciate the guidance. Thank you again for MacRuby! It's an incredibly elegant and beautiful thing, and I think that in the near future it's going to be very important to a lot of people. -- Ryan
Hi Ryan, As Jordan mentioned, the debugger is alpha quality :) It should be able to debug Xcode apps assuming you tweak a few things out, but not out of the box, I'm afraid. Also, the code has been neglected a bit as we have been working on other things. If you file a ticket we will try to get things better in the upcoming release. We could then document the process in a short tutorial on the website. Laurent On Nov 21, 2010, at 3:49 PM, Ryan Porter wrote:
Hello, and thank you very much to the developers of MacRuby. It's an amazing technology and I hope to see it continue to grow.
I've managed to figure out, after an hour or two of wasted time, that although MacRuby now includes a debugger, that debugger can't be used to debug a MacRuby Cocoa app. Not only through XCode, but at all. Is that correct? The release notes proudly announce that MacRuby now includes a debugger but they neglect to mention how to use it. After some research I eventually discovered that there is no way to use the debugger to debug a Cocoa app.
If that's true, then lack of a debugger eliminates any benefit that using Ruby could bring to the Cocoa experience. Objective C syntax is truly nasty, but if there is no debugger available for Cocoa apps written with MacRuby then it just doesn't make sense to use Ruby to make a Cocoa app. Especially with Objective C 2.0's simplified syntax and garbage collection. "You don't need a debugger for Ruby code", is simply not a realistic solution. TDD and BDD tools for desktop Cocoa apps are still inadequate, and even with TDD you often still need a debugger.
MacRuby isn't going to go very far if developers are forced to revert to printf debugging to build Cocoa apps. I don't mind if the debugger doesn't have slick XCode integration like GDB. But there needs to be SOME way to debug a Cocoa app or else the sensible path for developer productivity on the Mac will be Objective C 2.0 instead of MacRuby. Sacrificing any hope of using a debugger to gain relatively minor syntactic improvements is not a tradeoff that makes any sense. I don't intend to disparage MacRuby, I just want to share my perspective as both a professional Rubyist and a professional Cocoa developer. MacRuby is an amazing technology, but to gain traction as a realistic way to build Cocoa apps it will really need a debugger that works with Cocoa apps.
-- Ryan
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Jordan K. Hubbard
-
Laurent Sansonetti
-
Ryan Porter