18 points · by shortrounddev2 · 2y ago · 36 comments
It seems odd to me, but I also noticed a lot of my coworkers don't use the debugger in vscode or even the browser when I've shown them how. They opt instead to put console.log statements everywhere
Do you use a debugger or breakpoints? How common is it in your workplace for people to debug things the old school way and prefer plain text editors over IDEs?
(yeah yeah yeah, I think gdb has a tui mode now and the emacs debugger mode can probably do all that, solve world peace, and cook me an omelet).
I'm lazy, so if I have to do a lot of work to run the debugger, I don't.
First choice is to look at the code and reason it out. Then throw some printfs in. Third time's a charm, so that's when I reach for the debugger.
In some languages it is so easy, that you don't even have to use an IDE. Let's talk about JavaScript / TypeScript... you could use the browser developer tools to set break points, but for transpiled projects with boilerplate you can also use the `debugger` statement to hardcode a breakpoint.
function test(y) {
var x = 1;
debugger;
return x * y;
}
I wish they would take it one step further and integrate the timeless debugging[1] concept everywhere, where you could step forward bug also backwards. - slow compilation
- slow start
- lack of serialization
- complex algorithms
In all other cases I prefer debug logging. It’s just easier to scroll through a couple of pages than stepping in/out of functions and managing watches. If you compare my gdb session with my debug logs, in an ideal case they’ll be the same. The only difference is the amount of work I put into writing debug code or driving a debugger.In general I think that logs and debuggers aren’t enemies. A debugger helps with exploration in a specific moment or catching a specific condition or access. Debug logs help with matching expectations about a whole process. But both can do both.
Also, when I’m writing a service, I always write detailed operation logs. Saves your butt when something “costed us money” happened three days ago and you have to explain why. These never get turned off, regardless.
Debugging is so useful as a tool. There is nothing like it. They help a lot when there is complex state being manipulated. Instead of writing print statements, recompiling, repeat, debugging enables seeing everything, computing watch statements, deeply inspecting objects wherever you are and so much more. The biggest thing it enables is near-0 cost hypothesis testing when debugging.
When I was first learning PHP I spent a year or two without a debugger. The first time I tried one I learned about a whole bunch of global variables I had no idea about.
I recently set up nvim-dap and have wonderful debugging experience while still in the "purity of not using IDEs or debuggers" realm.
And long ago the Microfocus "animator" saved our bacon when a Peoplesoft COBOL program was blowing up mysteriously and blocking implementation.
I'm not sure I'd count the browser console as a debugger, but I do use it from time to time.
Not using IDEs isn't a bad thing, VIM is infinity customizable and you can setup your own work flow.
Normally I just sprinkle lots of logging statements around, which tell what is going on and when that occurs, and building a bigger picture of what's happening in the program.
I also turn on as many warnings as possible with the compiler. Fixing those warnings as they appear prevents lots of shit later in the development process.
Logs are useful when reproducing the issue is complicated or having no access to source code. Usually related to timing sensitive issues with systems that communicate with each other.
VSCode debugger is pretty useful with a GUI and the ability to set up conditional breakpoint.
There are however good videos out there for learning it.
But the people I've worked with used either use emacs, notepad++, vscode, or gdbgui to debug code.
Editing code at fly and moving program's current executing code ahead or behind is really handy, even for development purpose!
Perhaps if you work on very small projects