InfoQ

News

Debuggers considered Harmful?

Posted by Werner Schuster on Oct 22, 2007 08:00 AM

Community
Ruby
Topics
Programming ,
Code Analysis ,
Software Testing ,
Debugging
Tags
BDD ,
SmallTalk ,
Testing ,
Code Coverage
Giles Bowkett writes in Debugger Support Considered Harmful:
Asking why Ruby has weak debugger support is like asking why a dolphin doesn't have gills. Ruby has weak debugger support because Ruby programmers shouldn't be using a debugger. Ruby supports TDD and BDD better than any other language except possibly Smalltalk. Debugger support is for languages that you can't run tests against gracefully.
Note: TDD refers to "Test Driven Design/Development", BDD to "Behaviour Driven Development".

The article caused a wide range of responses, many among them from the Smalltalk community. These are particularly relevant, as Smalltalk and Ruby are close relatives. James Robertson, of Cincom Systems, went as far as recording a screencast, showing the usefulness of the Smalltalk debugger while doing TDD:
I wrote a test, ran it. It failed. I debugged the test, had the debugger create the missing method for me - whereupon I wrote the code for the method in the debugger, and ran the test again. That's not a crutch: it's taking TDD to the next level.
Avi Bryant, creator of the Smalltalk Seaside web framework, chimes in:
What Giles glosses over is how you come to understand the code in the first place. Nothing helps you understand code - whether you wrote it or someone else did - better than stepping through it in a debugger. Since Giles is a sometime screenwriter, maybe this analogy is appropriate: reading the code is like reading a screenplay. Writing tests is maybe like drawing storyboards (they help you visualize the final product). Using a debugger is like actually watching the damn movie. With a jog wheel so you can slow it down.
Blaine Buxton weighs in with another view of the role of the debugger:
Debuggers are great for exploratory programming when you are just trying out a new framework and seeing how it works. I like to walk line by line. I did this when I was learning Seaside and it was better than any documentation. Besides, watching beautiful code unfold in your debugger is nothing short of reading a great book. And when you're dealing with some ugly code, a debugger has shown me things that my eyes deceived me on when just looking at the code. Why dissect the dead animal when I can see how its organs work while it is still alive?
Ben Matasar comments that the name "Debugger" might be the problem:
I think the name debugger gives people the wrong idea about what it is, at least in Smalltalk. When I first came to Smalltalk in December of last year I tried not to use the debugger, and I did think of it as a crutch. Now I use it all the time to get my bearings around a codebase. In fact, I write quite a bit of my code directly in the debugger, often with my web browser spinning in the background waiting for me to send the response.
I now think of it as a method context browser, where you have an active REPL at every step of the call stack. This is nice because you can send messages to the objects, to poke them and figure out how they're going to respond to messages.
With this in mind, the classic debugger is the tool allowing to suspend execution via breakpoints or at arbitrary times and allowing to look at current state. It can be thought of as part of a group of tools that help the developer to understand how the system actually behaves at runtime - as compared to only looking at the source code. Other tools in that category would be coverage tools (eg. rcov) profilers, tracers, or loggers.

Another aspect of the original blog post is the suggestion that Ruby debugger support is lacking. It's not quite certain  what this refers to, though. The Ruby interpreter has debugger support, both slow versions written in Ruby and faster ones such as ruby-debug. This is also true for  JRuby, where  the faster solution (jruby-debug) is currently in the works. Other Ruby implementations, such as Rubinius have low-overhead debugging or use the underlying VM's debugging support.

Of course, the debugger implementation is just one part - a user interface for the debugger must be available too. But this too, is available in the Ruby space. All major and modern Ruby IDEs support debugging. RDT (now part of Aptana) has had debugging support for many years - the recent Netbeans' debugging support is based of the same codebase as RDT . Eclipse DLTK Ruby has debugging support, as well as the other - non Java based IDEs - such as Sapphire Steel's Ruby in Steel IDE, Komodo, etc.

What are your experiences with debugging Ruby?
Debuggers considered Harmful? by Philip Schwarz Posted Oct 23, 2007 3:05 AM
Re: Debuggers considered Harmful? by Werner Schuster Posted Oct 23, 2007 9:23 AM
Re: Debuggers considered Harmful? by Cedric Beust Posted Oct 27, 2007 12:10 PM
  1. Back to top

    Debuggers considered Harmful?

    Oct 23, 2007 3:05 AM by Philip Schwarz

    Uncle Bob's words In Debuggers are a wasteful Timesink

    I consider debuggers to be a drug -- an addiction. Programmers can get into the horrible habit of depending on the debugger instead of on their brain. IMHO a debugger is a tool of last resort. Once you have exhausted every other avenue of diagnosis, and have given very careful thought to just rewriting the offending code, *then* you may need a debugger.

  2. Back to top

    Re: Debuggers considered Harmful?

    Oct 23, 2007 9:23 AM by Werner Schuster

    I see the point... but still, I don't see how "a few well placed print statements" are better than a few well placed breakpoints. Even better: automate the debugger by scripting it - debuggers inside Eclipse can be scripted with JVM based languages (such as JRuby) which allows to automate setting of breakpoints, breakpoint handling, etc. Also: they're just absolutely indispensable as exploration tools... there's no faster way to understand how a complex or very dynamic system is implemented than setting a few breakpoints and stepping along to see what's involved. This is my experience, eg. from implementing support for programming languages in Eclipse - if I wanted to see what goes on when I hit Ctrl-1 in the Java editor, I set a few speculative breakpoints (ie. I'm guessing which classes/methods are involved), then a) see where this goes and b) know exactly what kind of objects and data are involved. With a system as extensible and modularized as Eclipse, this is the quickest way, much faster than trying to piece together the specifics from the source files. This is the same way that doctors use X-Rays, MRIs, or other similar tools to diagnose a patient - they still have the option of staring at the patient for a long time and trying to guess what's going on...

  3. Back to top

    Re: Debuggers considered Harmful?

    Oct 27, 2007 12:10 PM by Cedric Beust

    Big +1 in favor of debuggers as well, regardless of the language. Someone who uses judiciously both println statements and debuggers will always be more productive than someone who only uses println statements. I wrote a rebuttal to Rob's position on debuggers here some time ago: http://beust.com/weblog/archives/000055.html -- Cedric

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.