Python IDE | VS Code or Pycharm?

Click “Xiaobai Xue Vision” above and choose to add “star” or “pin

Heavy stuff, delivered as soon as possible

Editor’s Recommendation

In programming, VS Code has been the author’s primary IDE for 5 years. It may be incomprehensible that the author decided to replace it at this point in time. The article will share with you the reasons why the author made this decision.

Reprinted from丨pythonic biological person

background

You can call me crazy if you want. You might think that someone who has been using VS Code for 5 years would be crazy to want to switch out of it at this point. Indeed, I thought so before I came into contact with the JetBrains ecosystem. I am even willing to use my life to prove that VS Code is the best IDE on the market currently, just like the Apple M1 chip computer in the PC industry. But please allow me to give you some background.

I currently work at Blankly, which provides hedge fund cloud services. On the cloud service we provide, people can create their own trading algorithms in just a few minutes. One of my colleagues, Emerson, is a big fan of the JetBrains ecosystem. During a daily stand-up meeting, he even extended the meeting time in order to persuade us to try the JetBrains ecosystem. In order for the meeting to end the discussion on this matter early (so that the stand-up meeting could also end early), I reluctantly agreed. But who would have thought, here I am now writing an article about what finally convinced me to give up the IDE that has always been with me. So, if you are struggling with which IDE to use and have not considered the JetBrains idea at all, or you are interested in why I gave up VS Code, then this article is perfect for you to continue reading.

This article is based on some of my personal experiences using VS Code and JetBrains, and will conduct a comparative analysis of them from 5 aspects. And it explains the reasons why JetBrains has obvious advantages in some usage scenarios.

Code inspection and refactoring

VS Code: fast, simple, supports multiple languages

First of all, any programming language can be easily and quickly started and run in VS Code, so everyone also calls it an “editor”. Therefore, VS Code is the best choice for a full-stack engineer like me. Whether you need to frequently switch between Python and JavaScript, add a React App developed based on NextJS, or configure a Ruby environment on the Ralis system, VS Code can support these capabilities well and provide support for these development languages. Provides a series of out-of-box functions including lingering. Even if you encounter a certain function that is not available, you only need to search for one in its plug-in market and find a plug-in with this function to install.

Secondly, thanks to the support of a series of plug-ins such as Github Copilot, AI-based linting, auto imports, etc., VS Code has powerful linting capabilities. In VS Code, it’s very easy to configure whatever functionality you want whenever you want it. Many times, you just need to type the end character, and VS Code will prompt you with the content you want. But sometimes, people also collapse because of the failure of this linting ability. In fact, I often get stuck trying to figure out why a standard linting doesn’t work. Whether it is due to the multiple python environments I installed using Anaconda or the lack of installation packages, many times I cannot get the answer directly. In addition, VS Code’s linting capabilities for the JavaScript language are also very powerful, but it does not perform in-depth type checking for JavaScript. Fortunately, we can solve this problem through TypeScript.

b9b08e0634a3f0ab9f8e1e369768eb0c.png

As shown in the figure, because I forgot to switch the Python environment in VS Code, even though I have installed the relevant dependency packages locally through pip, the linting function of VS Code still prompts that the package is not found.

Finally, as an editor, VS Code does an excellent job of refactoring code. It does a great job with basic refactoring features like variable renaming, file moving, and automatic reference modification. But in terms of higher-level refactoring functions such as function movement, parameter renaming, code extraction, etc., it seems to be somewhat insufficient. Fortunately, however, just some basic refactoring functions are enough to meet most of our daily refactoring needs. In the five years I’ve been using VS Code, it’s met most refactoring scenarios I’ve encountered.

JetBrains: Standard, professional, strong support

First, JetBrains is a powerful IDE that includes a lot of unreasonable initial setup. When I first came into contact with it, I had to spend a lot of time on settings in order to make the code display more elegantly. However, it is inevitable to pay some learning time when switching between two IDEs designed for different usage scenarios. If one of my POST requests suddenly has a problem, I have to open PyCharm to see if there is a problem with my back-end API service; if I am in a recommendation project, I suddenly have new optimization ideas for the best recommendation algorithm. , I need to open CLion. However, thanks to smart recognition, I just need to take some time to practice switching code . to other scripts such as webstorm . and pycharm. when opening different IDEs.

Secondly, JetBrains’ engine is powerful. When I replaced my IDE with JetBrains, I was impressed by its powerful engine performance. When I see some red line warnings in the editor, I only need to use the shortcut command command + p to reload the current window, and these red line warnings will disappear, or some useful prompts will be given. This simple and responsive code inspection makes me feel better while coding.

5136daa687a7ab3cbc92f5f77947555d.png

As shown above, you only need one shortcut key to see all the referenced places.

Finally, JetBrains is powerful in terms of refactoring capabilities, and this is what really attracts me. Just last week, while building the final beta version of the company’s platform, I refactored and added some components to make them more scalable in the future. During this period, I moved about 200 components. When the project was compiled, no compilation exception was caused by reference errors, illegal or undefined components. Then, in VS Code, I was working on a data structure class project and just reorganizing two files broke the entire cpp code. To do this, I had to manually fix some component imports and function references to get the project to work properly. In addition, in order to ensure that we have enough refactoring tools, JetBrains also provides a variety of external tools such as safe deletion and global renaming.

5e293c7a1eb5e718b2a80dc39a1dbce3.png

Through JetBrains, you can clearly see all calls and context diagrams of variables that will be refactored or renamed.

824340541acf9b21a7ec7a91c5081957.png

Reading help function provided by JetBrains ecological IDE

Ability comparison

In general, I think VS Code and JetBrains are close in terms of code inspection and code refactoring. Both help people better debug and display code through functions such as automatic code inspection, code formatting, theme customization, etc. However, JetBrains has an excellent linting engine and side-effect-free refactoring capabilities. Therefore, if code decomposition and refactoring are important to you and your workflow, then I recommend you choose JetBrains.

debug

VS Code: Debug almost anything

VS Code’s super debugging capabilities are due to its powerful plug-in support. Every time you click the run button on the left side of VS Code, VS Code will generate a .vscode folder. This file stores a settings.json file, which contains all debugging-related configurations. For most languages such as Python, JavaScript, etc., it is very convenient to use VS Code as its debugging tool. Even if your environment is configured correctly, it will be more convenient to debug by clicking the debug button directly. Furthermore, it is very simple to change your current debugging content even by modifying the configuration in the settings.json file. However, if you use a specific build method or a specific platform language (such as: C/C++ language), since you need to set up gcc and clang, it will greatly increase the difficulty and complexity of debugging in VS Code. At the same time, set The debugging configuration of such files will also be time-consuming and laborious. In order to reduce this time investment, I tried to copy the setting.json file of other projects into the current project, but the effect was not satisfactory. It took me many days of adjustments to make the current project run normally. At my university (University of Michigan, Ann Arbor), in order to reduce everyone’s effort in debugging configuration, they maintain a common settings.json file for everyone to use. But even then, people still have to spend time adjusting the settings.json file.

e5c1afbc342a49f32000c992f983721c.png

The image above shows a minimal configuration required for debugging C/C++ programs on MacOS

During the actual debugging process, VS Code can set debugging breakpoints, identify variables, and add variable observers very well in the debugging console. However, it would be nice if these features could be set directly in the code panel instead of the side panel.

Fortunately, plugins and multi-language support are VS Code’s biggest strengths, making it possible to set up code debugging in minutes, or even seconds. For some simple debugging scenarios, VS Code’s debugging capabilities perform very well. However, when special languages need to be debugged, VS Code’s debugging capabilities are often incompetent. At the same time, I also found that when the program needs to use larger heap memory, the debugger of VS Code will freeze until it crashes.

JetBrains: a debugging monster

Compared with VS Code, JetBrains has stronger debugging capabilities. Since all series of JetBrains IDEs run based on configuration, you can start debugging any program by clicking the debug button. If you want to set a global debugging breakpoint, you only need to press the space bar at the line number in the editor. This feature greatly improves the program debugging experience. In addition, the JetBrains series of IDEs have many other functional highlights throughout the debugging process. For example, when entering the debugging process, the definitions of all variables within the scope are visible to the definer. This allows us to observe the changes in the current variable value in a very detailed way. I was impressed by the process of debugging a program with Pycharm a few days ago. When I run debug in Pycharm and try to see the values of the dataframe, as soon as I click on the dataframe variable and press view as the dataframe, Pycharm opens the dataframe in SciView and displays all the dataframe values and column headers:

e021124fcc9e622278f301441bd4c3a4.png

The figure above shows the monitoring of running debugging and variable value changes.

As shown in the screenshot above, the bottom window displays all values in the scope. The drop-down menu of history_and_returns displays all attribute values of the dictionary object and the data frames nested within the dictionary object. The right panel, like SciView, displays the data frame nested in the dictionary. Being able to get this deep into the code without setting up any print statements or stack traces is very useful for developers. Just imagine, when the assignments of all variables are displayed next to them in the editor, we can easily find logical errors in the loop, fix failures caused by indexes, and even do some more in-depth logical reasoning.

Like other IDE debuggers, the JetBrains debugger also provides step-by-step debugging functions such as next line and entering a function. In addition, JetBrains’ Run to Cursor is a very useful function. It allows people to debug breakpoints just like setting breakpoints by placing the mouse. This ability to set breakpoints anytime, anywhere and take effect immediately completely changed my way of debugging code and greatly accelerated my programming speed.

Ability comparison

Program debugging is one of the most common things developers do every day. Therefore, I think that when developers choose an IDE, whether the IDE has a good debugger is a factor that must be considered. Both VS Code and JetBrains provide very reliable debuggers, but I must say that JetBrains is slightly better than VS Code in this regard. Because JetBrains can display variable values directly next to variable declarations, this makes tracking a large number of variables easier to manage. In addition, JetBrains’ debugger is more powerful and stable, and it does not require complex settings like the VS Code debugger. Therefore, combined with these factors, JetBrains debugging can help us save more debugging time, which also makes JetBrains more attractive.

Integrate Git

VS Code: Built-in powerful source code control management

Anyone who collaborates on a team or cares about code security knows the importance of Git in their workflow. Git-based version control is an essential feature for any modern editor. The integration between VS Code and Git is very good. When you open a working directory, it will automatically detect whether it is a Git repository. If so, then it immediately provides many native Git commands like push, pull, commit, etc.

In the Git panel of VS Code, people can clearly see which files have been modified and synchronize them easily. At the same time, in the panel, you can also create branches and clone warehouses. VS Code always tells you clearly what to do, which is one of the reasons I like it. When it detects a file modification, it will immediately prompt you to submit, and when submitting, you will be prompted to include submission instructions. In addition, when submitting, it will also detect and synchronize the local branch and the remote branch. At the same time, it also provides very stable rebasing functionality.

5e3b58d9c01d11def8f9a913f39a0276.png

You can clearly see where conflicts need to be merged in the line

The ability to reasonably handle conflict merges is a major advantage of VS Code. With the automatic conflict resolution provided by VS Code, I can choose to use the current changes or choose to use the incoming changes with the click of a button. This way of resolving merge conflicts saves me a lot of time.

JetBrains: No need to use the command line for source code management anymore

After making the full switch to JetBrains, I barely touched my terminal command line. JetBrains provides overall functions such as source code management including submission, conflict resolution, branch switching, branch comparison, etc. From my experience, JetBrains is much better than VS Code for source code control. Below I list some screenshots of my experience:

6c938f6c6e1a3599f9e43a9f18bf31a8.png

Compare a file between two branches

3d9289c01f1658bc9738fec9c38b98ec.png

Built-in branch details display

Detailed git log

Ability comparison

In terms of Git integration, both JetBrains and VS Code provide complete and identical functionality. No matter which IDE you choose, there is sufficient functional support for source code management. Therefore, this aspect cannot be used as a consideration in choosing an IDE. It is just a matter of personal preference. For example, when resolving merge conflicts, I prefer the way JetBrains displays conflicting files separately compared to the way VS Code displays conflicting files stacked in one file.

Scalability

VS Code: rich extensibility

VS Code is one of the most extensible editors, and integration capabilities and extensibility are its core features. Among the many extension capabilities, Python extensions, remote development extensions, and some IntelliSense-driven extensions are currently the most popular. In addition, VS Code also has some cool features, such as code formatting through Prettier, theme customization through icons and code editor themes, etc. Every item or feature provided by VS Code is fully extensible, and the extension itself may also be a process of enhancing extensibility.

6b3990f70c2cf7d30f86bd33e18ce1f1.png

Support for remote docker containers is one of my favorite extensions of VS Code. With this feature, users can program remotely inside a docker container in VS Code. If you have docker installed in your local or remote environment, you can easily run your code in VS Code and complete all the things that you previously needed to do in docker. Want something a little more fun? What about remote development via SSH? The extension plug-in developed by Microsoft allows people to enter the server-side development environment through remote SSH in VS Code and perform remote development as if it were local. If you want to integrate these functions in VS Code, you only need to click to install it and it will run successfully. All these functions make VS Code great.

JetBrains: integrated ecosystem

For JetBrains, extensibility is not a point that needs to be highlighted, because you will find that most of the features you need will be released with the release of IDE versions. The advantage of installing a powerful IDE for a certain language is that when we need some new features, we may only need to upgrade the IDE version to have them, without having to go to the extension market to find them.

For example, JetBrains provides strong built-in support for docker. All JetBrains IDEs provide complete control over all parameters, names, labels, ports, and environment variables through an easy-to-use GUI simply by specifying a configuration type file such as a Dockerfile. When running, the IDE integrates docker to provide you with docker’s build logs, running logs, environment variables, and visual integration configuration information:

259327d4df916b769e9c756f2fa32a62.png

In terms of integrating third-party capabilities such as FastAPI, Flask, and shell, JetBrains provides the same capabilities as integrating docker.

In addition, JetBrains IDE also has a rich plugin ecosystem. For example, I can install specific plugins for Verilog and Matlab support. But what’s interesting is that these lightweight plug-ins actually provide a better programming experience than the locally installed Matlab and Quartus (Verilog development environment) environments.

Ability comparison

There is no doubt that both have extensive community and market support for extensions or plugins. Both IDEs have different features. You may want to enrich each of the two editors with features that are lacking in each other. However, VS Code has a slightly larger community and therefore has more extensions and capabilities like remote container extensions, which allow us to iterate faster. Therefore, if you have more needs for customized extensions such as Docker in your daily work, then VS Code can be said to be your exclusive IDE.

Collaboration

VS Code: Real-time sharing based on plug-ins

Although VS Code itself does not have built-in real-time sharing capabilities, Microsoft has developed a plug-in for it that does. In addition to this, now one can even share in real time by accessing vscode.dev directly using a browser. This diversity of needs is why VS Code is so popular. As long as you have a good network environment, the real-time sharing experience will be great. In the process of real-time sharing, people can work together as if they were face to face. At the same time, in terms of source code control, VS Code will also always track those who help the author submit the code. These let us see how easy it is to enable real-time sharing in VS Code. So, in my opinion, VS Code is better at real-time sharing than any other IDE and editor on the market.

However, there are still some things that need to be paid attention to when using the real-time sharing function of VS Code. Below I will give an example of using the real-time sharing function in a Vue.js project. When sharing Vue code in real time, some plug-ins including Vetur (Vetur is an important plug-in for Vue visualization) will not be shared. This shortcoming often leaves people in trouble and irritated. Fortunately, such defects will only affect certain users (in this case, it will only affect Vue users). In addition, what I hate the most is that in real-time sharing, the undo function is actually bound to the machine instead of the current user, which causes my undo function to be confused between local and remote.

JetBrains: secure, distributed

All IDEs in the JetBrains ecosystem provide a lot of settings for code sharing and online collaboration. These settings vary according to different security levels. An impressive capability I recently discovered is that through projector technology, any JetBrains IDE can be run in a docker container. This allows me to connect to a JetBrains IDE running on a cloud service while browsing Code in the browser using the full functionality of JetBrains’ IDE. So now, I can code securely anytime, anywhere with just one password and using a headless service. This is just one of many shared configurations across JetBrains.

Among all JetBrains IDEs, real-time sharing through Code With Me is the mainstream method. This approach allows you to view other people’s projects directly in your local IDE. At the same time, you can also use other people’s development environments to run projects just like using your local development environment. An impressive scene is that one of my team members encountered a python problem. He initiated a real-time code sharing with me through Code With Me. Through this sharing, I used it in my own IDE as if it were local. Using his configuration and debugging the code, I easily helped him solve this problem.

It’s amazing how good a variety of different shared IDE solutions are in trying to improve security, collaboration, or how distributed teams work together.

Ability comparison

Two years ago, I might have dismissed the live sharing feature as irrelevant. In fact, two years ago I didn’t even know that code collaboration capabilities existed in IDEs. Because two years ago, when we needed to work together, we would not initiate remote collaboration through the IDE, but sit directly in front of the same machine. But now due to the impact of the new crown epidemic, this kind of face-to-face collaborative work is no longer a luxury and has become extremely difficult. Because of this, both IDEs provide strong support for real-time code sharing. However, due to the issues with the undo feature in VS Code, I highly recommend JetBrains. Also, support for video and audio calls and the ability to track Git between users are equally important.

Summarize

In addition to the 5 comparisons listed above, I also know that compared to VS Code, which is completely free, JetBrains charges a certain fee for non-student users. This may be one of the reasons why many people do not consider JetBrains. However, for me, in the few months of using the JetBrains ecosystem, it has given me a very good experience. And, I can’t wait to use them more in my work. So I hope that even though JetBrains costs some money, you will consider it.

Original link: https://blankly.finance/vscode-vs-jetbrains Author introduction: Jeremy Liu is a full-stack engineer who currently works at Blankly as the chief engineer. Invasion and deletion~

Download 1: OpenCV-Contrib extension module Chinese version tutorial

Reply in the background of the "Xiaobai Xue Vision" public account: Chinese tutorial on extension module, you can download the first Chinese version of OpenCV extension module tutorial on the entire network, covering extension module installation, SFM algorithm, stereo vision, target tracking, biological vision, super Resolution processing and more than twenty chapters.


Download 2: Python visual practical project 52 lectures
Reply in the background of the "Xiaobai Xue Vision" public account: Python visual practical projects, you can download them, including image segmentation, mask detection, lane line detection, vehicle counting, adding eyeliner, license plate recognition, character recognition, emotion detection, text content extraction, 31 practical vision projects, including facial recognition, support rapid school computer vision.


Download 3: 20 lectures on OpenCV practical projects
Reply in the background of the "Xiaobai Xue Vision" public account: OpenCV practical projects 20 lectures, you can download 20 practical projects based on OpenCV to achieve advanced OpenCV learning.


Communication group

Welcome to join the public account reader group to communicate with peers. Currently, there are WeChat groups for SLAM, 3D vision, sensors, autonomous driving, computational photography, detection, segmentation, recognition, medical imaging, GAN, algorithm competitions, etc. (will be gradually subdivided in the future). Please scan the WeChat ID below to join the group, and note: "nickname + school/company + research direction", for example: "Zhang San + Shanghai Jiao Tong University + visual SLAM". Please note according to the format, otherwise it will not be approved. After successful addition, you will be invited to join the relevant WeChat group according to the research direction. Please do not send advertisements in the group, otherwise you will be asked to leave the group, thank you for your understanding~