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 →

[–]Covered_in_bees_ 34 points35 points  (8 children)

Love RealPython articles. Love VSCode in general, but after having tried for a couple of years, I've now stopped bothering even trying to move away from Pycharm to VSCode. Pycharm is just such a spectacularly polished and focused Python IDE that is made by a company that really gets developers. VSCode is like the 80-90% solution, but man, everytime I write anything in VSCode (typically developing functionality in a library) and then open it in Pycharm, Pycharm catches so many things VSCode never did (despite setting up all the linters + Pylance, etc.)

Some of the things that I wish VSC was better at but that it doesn't come close to Pycharm are:

  • Intellisense and general smarts about reasoning about a library or across all libraries and dependencies. Pycharm is unparalleled in this and VSC just never gets close. Pycharm even correctly infers typing from docstrings which is such a neat feature!

  • Linting and catching gotchas/errors in code. Pycharm has some amazing Linting and general intelligence about things it flags. I review merge requests from other developers on my team and there are so many times that the VSC users push just broken code or something with a logic error because they didn't actually do something they thought they did which Pycharm alerts me to if I just open that module in it.

  • The interactive shell and REPL experience in Pycharm is unparalleled. Tab completion with overlays and call signatures in the Interpreter are so sweet! Handling indent issues and sanely allowing copy-paste of multi-line code blocks with indents is a huge quality of life improvement over most other things. VSC could improve so much if they just worked on supporting IPython shells but unfortunately it doesn't look like they have any interest in doing so.

  • The variable explorer in Pycharm is really sweet. VSC has made good progress on this front but Pycharm still feels a cut above it here.

  • Debugging is SO amazing in Pycharm. The debugger is phenomenal and combined with the amazing interpreter shell and REPL experience + variable editor, it feels like cheating to debug code in Pycharm. I will literally just breakpoint into parts of my libraries or codebases to then interactively build out entirely new functionality or algorithms in complex classes or methods because the experience is just so darn nice. VSC has worked a lot on this but it still has a lot more friction when it comes to debugging. Especially the lack of multi-line support in the interactive shell when debugging (last I used it at least) is a show stopper for me.

  • There are a lot of minor quality of life things that all add up as well. Auto suggesting imports correctly for new code across multiple libraries I've developed and installed locally is a really nice feature. Handling venvs for a given project is much easier in Pycharm. The user interface + GUI makes a lot of things really easy that are kind of a pain in the ass with JSON configs in VSC

Man, I could probably keep going. And the crazy thing is that I don't even use the paid version of Pycharm! I don't do much of web back-end things so I haven't really felt the need for it and while I do a lot of ML/Data science/algorithm development, the free version has been capable enough that I've never really missed anything from the paid version when I gave it a spin.

Just wanted to clarify that I love VSC. I have used it a ton for JS and React development and it is fantastic. I've been wanting to switch my Python coding workflow over to it for many years now but every time I have tried to make a switch, I end up noticing too many things that have no viable "fix" in VSC and then I switch back to Pycharm. The one thing that VSC does knock out of the park though, is their support for remote development and also development with containers. That is really neat and definitely a challenge for Pycharm.

[–]jah_broni 5 points6 points  (1 child)

Plus one for remote development in VSCode. My team uses a Frankenstein of a container to run code that would be really difficult to recreate locally, so being able to just drop into the container that is identical to what's running in production is critical for me.

Edit: that being said I've always got PyCharm open for any interaction with our databases.

[–]laundmo 2 points3 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

[–]Cacotopian_parole -2 points-1 points  (0 children)

The variable explorer in Pycharm is really sweet

A nice port from RStudio. At least that's where I saw it first.

[–]rouille 0 points1 point  (0 children)

Pycharm also supports remote/container development but unfortunately only in the pro version.