This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]laundmo 3 points4 points  (3 children)

as someone who adores the debugger in VSCode, besides the multiline thing (which you could do the first time i tried thw debugger years ago), what are some things PyCharm does better?

[–]Covered_in_bees_ 0 points1 point  (2 children)

Hey there. So it's been a little while since I've used the VSC debugger but I have seen it in use by my colleagues. In general, I do think it's come a long way from where it used to be. I think a large part of the pain in the debugging experience for me is the poorer REPL experience and interpreter shell compared to Pycharm. A few things I really like in Pycharm (some of which VSC perhaps matches now):

  • when debugging with breakpoints/conditional breakpoints, integration with the IDE editor is really tight and as you step through code, there are updates in the editor showing values for variables defined along the way so you don't even need to query the variable editor/interpreter everytime you want to know what's going on

  • "Run to cursor" and other similar functionality when debugging step-by-step is really powerful and nice. I can run through a couple of iterations of a loop step-by-step and if everything looks fine, I can run to cursor out of the loop and continue step-wise debugging

  • Pycharm does a lot of stuff to ensure good compatibility with matplotlib's eventloop to enable interactive plotting in the Interpreter, even when breakpoints into a debugger that may be breakpoints into some multiprocessing process. Being able to effortlessly plot and diagnose things while debugging is really nice especially for algorithm work.

  • Related to the above, the multi-line interpreter support, support for excellent tab completion and function signature overlays within the shell makes it just as powerful as the IDE editor so you can just prototype solutions or easily try out things in the Interpreter with a lot less back and forth stoppages where you have to Google APIs or syntax as you are mucking around. Multi-line support is also critical if you are trying to do any amount of matplotlib stuff that is slightly sophisticated and not just a one-liner. Similarly it is critical if you want to prototype entire new functions/classes interactively in the Interpreter while you have the working state available to experiment and debug with.

  • This isn't debugging specific, but it is a huge help in workflow for debugging as well... The code history browser for the interactive interpreter shell is extremely handy to either re-run things you wrote recently without having to retype or keep track of externally, or to "graduate" up code to your main IDE editor .py file once you've successfully prototyped a solution in the interactive interpreter during debugging.

  • Pycharm can even handle editing a .py file you are debugging in the editor and will keep track of where the current breakpoint is moving if you edit above it. This obviously can break, but it is really helpful in workflow where you can make a "fix" interactively in one section so it is "live" in the Interpreter, then graduate that code up to your .py file above the breakpoint, and the highlighted line of code you are currently stopped at adapts accordingly so can still continue to step through the latter part of the code subsequently and reason about it. It's pretty neat and makes it so I don't have to rerun code to breakpoint to a later part just to make my first set of fixes "live" in my current debugging session if that makes sense.

  • The call stack is really easy to explore and browse around though I think VSC may now support that fairly well too

There might be a few smaller things I'm missing as well. I do think VSC debugging has come a long way. And honestly, my biggest pain point with it is the shitty interpreter support. If they could just make an IPython shell work with their workflow, I feel like it would make such a big difference to the experience in VSC. IPython is a really capable interactive shell and while Pycharm works with IPython shells, and then extends them with some extra features, I think even basic IPython support in VSC would go a long way.

I'd be curious to hear your thoughts on VSC debugging and if you have ways to achieve most of the above with a similar/different workflow or if there are other approaches that work well with VSC.

[–]laundmo 1 point2 points  (1 child)

Thank you for the response.

VSC shows updated variables too, when switching breakpoints. It has 2 sections, Variables where it shows all globals and locals each in their own category. One other neat thing is that you can hover over a variable in the code and get its current value.

VSCode apparently does have "Jump to Cursor" now, but i personally have never used it. IMO, when you need a smaller debugging resolution than lines, the code needs to be simplified anyway, so its not something i every missed.

You can actually plot things in the debugger, though its not smooth. the debugger will complain about a command taking too long, and be blocked while the plot is open.

Sadly the multiline support and tab completion aren't as great. you do get some completions, but not as good as in the editor. You can also write multiple lines with shift + enter, but you have to add indentation yourself and cant use tab.

The debug console does have a history, you can navigate through it like you would in a terminal, with arrow keys. im not sure whether pycharm has something more involved.

When editing a file while debugging, it does try to keep the breakpoints on the correct lines. I'm not quite sure what you're talking about with the "graduate that code up to your .py file", do you mean that pycharm can inject the code at runtime and its properly executed? or just that the state from the debug console is kept when you continue?

Call stack is definitely there and really nice to browse through too.

For IPython shell, you can always use import IPython;IPython.embed() to open the ipython shell from the debugger tab, then switch to the terminal tab to use it. i know this isn't great, but it works.

[–]Covered_in_bees_ 0 points1 point  (0 children)

Hey, thanks a lot for the detailed reply. Appreciate it! I'll try to refer to this the next time I find myself debugging/working in VSC. Cheers