News for hackers. Stuff that matters.
Re:Reasons To Give The Vim Text Editor A Chance by eropple on Sunday May 15, 2011 @07:13PM (#2551053)
Spewing print statements all over a piece of code is as bad as any other shotgun debugging technique. The reason breakpoints and watches were invented were to reduce reliance on bad ways of doing things.
Re:Reasons To Give The Vim Text Editor A Chance by jrockway on Sunday May 15, 2011 @07:55PM (#2551140)
What's good about print statements is that they don't require me to do anything more than once. When you run code in a debugger, there is a lot of manual interaction involved. continue, break, see where you are, think about that, poke around, repeat. With print statements, you run your test, analyze the output, and make the changes. It's all automated except for the analysis step, which is all the human should be doing.

If you need breakpoints, watchpoints, and a GUI to click around in, your code is too complicated and unmaintainable, which is probably why you need a debugger in the first place.

Re:Reasons To Give The Vim Text Editor A Chance by eropple on Monday May 16, 2011 @09:51AM (#2552477)
Manual interaction? Sorry, but I'm still very skeptical. Pausing in a debugger does not require materially more "manual interaction" than endlessly running your program to spit out some printed statements--it just front-loads the manual interaction so you're doing it sooner and, if you're doing it right, doing less of it. A debugger allows live autopsy, which is far more valuable than this silly print-statement thing--when your print statement does not return as expected, you are not much better off with your print statements than just seeing the broken output of the program.

Couple live autopsy with live edit-and-continue and you've got a recipe for a considerably more effective way of debugging code.

And "your code is too complicated and unmaintainable if you need a debugger" is preposterous on its face if you've ever...oh, I don't know...written a driver? Or any other remotely complex (you're conflating complicated and complex) task with a significant number of interlocking parts? (Hell, one could just as easily say that your code is too complicated and unmaintainable if you're barfing print statements all over the place.)

Re:Reasons To Give The Vim Text Editor A Chance by jrockway on Tuesday May 17, 2011 @02:10AM (#2555489)
You "step over" instead of "step into". Now what? You have to start over.

With test cases and print statements, starting over is free. If you need more information, edit the code to give it to you and re-run.

Getting a debugged program back to the desired state is, in my experience, difficult even with an automatic test. Not only does the program state have to be right, but so does the debugger state. Without the debugger, you have half the state to bother with.

Re:Reasons To Give The Vim Text Editor A Chance by ams6110 on Sunday May 15, 2011 @08:51PM (#2551238)
I like logging for this, but the concept is basically the same. Being able to switch on debug logging on a running system has saved the day more than once for me.
Re:Reasons To Give The Vim Text Editor A Chance by eropple on Monday May 16, 2011 @09:53AM (#2552483)
Thing is, logging and debugging are not in opposition. My current web app is...well, verbose is probably putting it mildly. But when developing locally, if something goes sideways I just say "hey, stop here" and I can introspect the entire kit and kaboodle without even having to re-bounce the debug server (and certainly without stopping it to bung in a bunch of print statements).
Re:Reasons To Give The Vim Text Editor A Chance by blackman on Monday May 16, 2011 @12:08AM (#2551607)
I agree somewhat (although I do feel that debuggers are useful) in that IDEs can influence the design of your program by encouraging a debug first development style similar to "programming by coincidence"
Re:Reasons To Give The Vim Text Editor A Chance by phaylon on Monday May 16, 2011 @11:01AM (#2552720)
Nobody is putting print statements all over the place. At least I don't do. I set it where I want to inspect values. If you want a separate piece of software for that, more power to you, but please don't tell me my nails must be crooked because I use a different hammer than you.
Re:Reasons To Give The Vim Text Editor A Chance by eropple on Monday May 16, 2011 @01:14PM (#2553292)
This assumes you know ahead of time exactly what values must be inspected to solve the problem. This is frequently very much not the case, especially if you're ever working on somebody else's code.

So, yes, your nails may be straight, but your chosen (regressive) technique leaves you with no way to know if they're straight and with only the option of pounding harder and harder if the nail doesn't go in the first time. Enjoy!

Re:Reasons To Give The Vim Text Editor A Chance by phaylon on Monday May 16, 2011 @01:32PM (#2553355)
Of course I know, that's why I read the code for. Understanding the code base is my job. Using print statements to exclude factors which could contribute to the problem is not different from using a debugger to do the same.

If you debug without knowing what you're debugging and just looking for getting it running, it sounds like you're the one doing the shotgun-programming/debugging, separate debugger or not.

Re:Reasons To Give The Vim Text Editor A Chance by Total_Meltdown on Monday May 16, 2011 @01:50PM (#2553432)
I'm not sure what code you write or what it's for, but in the real world, sometimes we deal with buggy, archaic and downright bizarre code that we didn't write, and sometimes we have deadlines.

So, yes. I use a debugger, so that I can spend some time at home too. Because as nice as the office is, it's summertime, and there's beer in my fridge.

Back when I was seventeen and staying up all night writing a video game engine though, I definitely would have been onboard with the whole print debugging idea.

Re:Reasons To Give The Vim Text Editor A Chance by phaylon on Monday May 16, 2011 @02:12PM (#2553535)
Nice ad hominem, doesn't work though. I'm 30 and have been developing for 14 years now. And yes, it's real world. And it's mostly Perl, so I do know about "buggy, archaic and downright bizarre code." I'm still more productive with print statements than having a separate system poke around in the applications.

But again, I must be wrong because I'm doing it different, right? So the only option can be that I'm too young, don't know what I'm talking about, or just lack experience in general, right? There couldn't be a possible way that someone else uses a different solution that works just as fine for them, right?

Considering that I never said "Don't use a debugger." only that "I don't need a debugger", you guys seem pretty worked up considering that you're claiming you're the more relaxed one.

It's a tool, don't take it personally that I have a different method that works. It doesn't invalidate yours. At least not in my view.

Re:Reasons To Give The Vim Text Editor A Chance by eropple on Monday May 16, 2011 @02:22PM (#2553571)
Honest question (as I avoid Perl like the plague) - is there an introspective debugger on par with Visual Studio's in Perl-land?

Because if you're leaning on print statements in absence of appropriate tooling, I can understand that. When the tooling is available, however, I am skeptical of claims as to enhanced productivity or any other positivity coming from it.

Re:Reasons To Give The Vim Text Editor A Chance by jrockway on Tuesday May 17, 2011 @02:09AM (#2555487)
There's a way to get a good answer from someone, compare his language of choice to a deadly disease. And then ask if it's as good as some proprietary crapware.

What does visual studio? Show the value of variables in separate windows as the code runs? Yes, the perl debugger can do that. You can also inject code and poke the entire program state.

The perl debugger is a perl function that is called for every line and every subroutine entry. Use that to build whatever tool you want, and good luck finding that in Visual Studio.

Re:Reasons To Give The Vim Text Editor A Chance by eropple on Thursday May 19, 2011 @08:28PM (#2565923)
"Proprietary crapware." Yeah, that's the sign of a really well-balanced, competent developer.
Re:Reasons To Give The Vim Text Editor A Chance by phaylon on Monday May 16, 2011 @02:29PM (#2553595)
I never said I have enhanced productivity over using a debugger. I said I have no worse productivity.

There's a debugger, there's a REPL, and in general lots of tools which I use if I see the need (the NYTProf profiler would be one). Using a debugger in this scenario (with an interpreted language) just doesn't give me any enhanced productivity over what I'm doing now.