There’s a Ruby debugger?

This article was modified from its original published form. The most recent modification was on2015-06-14.

Yeah. My post title is a little over the top, but since I started using Ruby in early 2002, I can’t count the number of times that I’ve used the Ruby debugger. After all, how does one count the empty set?

This is not to say that I haven’t had to debug; it’s to say that where tests haven’t sufficed in helping me specify behaviour correctly, Kernel#p has helped me find what did go wrong so that I could fix the problem and add a test (where appropriate; PDF::Writer, for example, has no tests). So I think that Giles Bowkett is right, even though I’d say that debuggers aren’t harmful; they’re pointless in a pointerless language.

I find that I mostly use the debugger in C/C++/C# for stack traces in any case. It’s a bit less painful with a good IDE, but depending on the nature of the problem that I’m debugging (especially one in a tight loop), I will usually add print outputs to a log file and debug based on those logs. Yes, even when there’s pointers involved (because it’s usually a binary search approach where I figure out where a pointer went bad over a large run).

  • 2015-06-14: My position on this has changed. Now that I am developing Rails applications, and the deep magic it introduces, I find myself using either binding.pry or byebug fairly often, especially when debugging tests. I don’t use either very often in the various gems that I maintain.[ back ]