Ask HN: How often do you use a debugger?
I wanted to know if the HN community uses a debugger during development.
I have this feeling that developers who create native apps use it a lot. But web developers don't, from what I see, most of web dev use print/echos/var_dumps and so on.
Why aren't we all using debuggers ?
16 comments
[ 3.3 ms ] story [ 30.2 ms ] threadThe only time I don't use one is when I need to debug an issue that occurs only on a remote server (our sysadmins don't like opening ports for that sort of thing).
I also make heavy use of logging statements, but these are usually left in for debug builds and used to help find unexpected bugs rather than active debugging.
Just recently had to start using JavaScript so I have spent some times figuring out FireBug and its debugger. I must say I was pleasantly surprised that it works well.
Edit: to more directly answer the question, when I am programming all the time, not an hour goes by (when programming) without using it.
I've done Java,c#,vb6,vb.net,c++ and have used a debugger for every project.
Does anyone remember the days before firebug doing js Dev. Using alerts() for debugging... god I'm glad web tools have got allot better.
Lack of good debugging support is a good reason to avoid a platform. Logging, screen writes, dumps, are awful ways to work.
PHP at compile time has it's own built in error warnings (for those unlucky enough to get PARSE ERROR as often as I do) which can be useful, although for loops the line it finds the error on can sometimes be completely wrong, and normally derivative of another error.
On the server side, print and vardump statements will provide the developer the desired information in a one-second refresh of the browser. A debugger will need to be run on an independent server instance which can take time to configure and start up. If the development environment is not already set up for this, running a debugger can take longer than identifying and fixing the bug using print statements.
Of course, you could just write correct code, but no one is perfect and mistakes do happen. Would be better if the errors it found were displayed in a more clear form of english instead of generic error names, but it is better than looking over line after line trying to find that darn missing semi-colon.
Python/Django: never. I don't think I've ever used a debugger here. I tend to write unit tests instead.
Ruby/Rails: same as Python, never. Unit tests all the way.
JavaScript/CoffeeScript: occasionally (once a week?). Usually in chunks of code that are hard to test (DOM manipulation, generally). Usually use Jasmine and write a unit test, especially if it's a logic-related problem.
C#: I've been working on a legacy codebase written in C#, and I tend to use the debugger quite liberally here. When I got there, the codebase was around 36kloc with 0 unit tests and many global variables. Most of the code was not written with testing in mind.
Java: Not often. It's been a while, but most of my Java projects were greenfield projects, so they were written with a JUnit suite from the ground up.
Objective-C: Occasionally. The last project I worked on was using Cocos2D and network stuff. Neither was particularly easy to write tests for, so the debugger was useful for inspecting state when things got weird. More often, I would add a few NSLog statements instead, to capture long-running state changes so that I could reconstruct a model of what went wrong and when.
Why? I'm not sure. Maybe because the Ruby has such good unit test support, and logging is pretty painless. It could very well be that I'm missing out by not using ruby-debug or some other tool, though.
In Xcode, the path of least resistance is the debugger. Maybe it's because I'm less familiar with Cocoa, but the code just seems more complicated and harder to trace from start to end. The debugger really helps with that. Even there, though, I use a lot of NSLog(). This helps when you have to track down a changing situation, and can't quite figure out when or how it breaks. Just log a bunch of stuff and let it rip.
Edit: Hurp durp, XDebug has remote debugging. I've never actually used it...although I think I'll check it out soon.