PyCharm Vs Visual Studio Code For Python Development

Introduction 

 
One of the most primary questions in the minds of a development startup, a beginner, is - "which language to use, and Okay if I do have a language, which IDE to consider using with it?" These are merely questions. It goes down in the stack to understand more about different aspects of the IDE, such as,
  • Productivity
  • Performance
  • Extensions and Add-ons
  • Ease of use
  • Learning scope
and much more. All these key points are focused toward the development of a software engineer, as he gets to understand how to develop a vital piece of software. For the time being, I have just started out with Python development. Before you start asking me, why I did that,
  • Python is amazing.
  • Python is being used for many machine learning libraries.
  • Python is portable (just like .NET Core, which is my first love)
  • Scripting is sometimes fun with Python (as compared to bash, command prompt or PowerShell)
  • Open Source software love Python (Blender, GIMP, TensorFlow, etc. etc. etc.). 
Long story short, Python is a great language to learn and sometimes fun when your C# or C++ code is no longer building. However, if you want to upgrade your skills to a professional Python developer, because Python developers also earn, the developer for Visual Studio Code Python extension was hired by Microsoft. Read the full story at Python Engineers team blog post on MSDN. And, Microsoft is still hiring more Python developers. 
 
So that was it for basics and introduction. Now the real stuff begins. Python can be programmed in so many ways, you can use your text editor and then do a simple python main.py, to execute the code. You can then extend the support to virtual environments and use other IDEs such as Spyder or interactive shells, IPython let's say. But for hardcore Python programming, you need something more than just a text-editor, Python interpreter, and a linter.
 

PyCharm and Visual Studio Code

 
PyCharm by IntelliJ and Visual Studio Code by Microsoft are the two primary IDEs that I keep using for Python development. Both IDEs support basic Python development, autocomplete suggestions, linkers, and extensibility of the IDE to support custom toolchains during development. I used Visual Studio Code a few months ago and I was let down, I admit. Then, I shifted my interests to PyCharm for a while. But, (as with anyone who has ever used PyCharm, IntelliJ IDEA, Android Studio or any similar IDE by IntelliJ; and yes I have not used the CLion, so I cannot say anything for it but data suggests it's no different) you know that PyCharm is a memory and CPU hog. I cannot afford my machine to go down even for a minute, thus it kept itching deep in my mind to change the IDE. I can afford to go to plain text editor if I have to, but I cannot afford my machine getting stuck. Anyways, that is when I started testing PyCharm vs. Visual Studio Code battles and in most cases, Visual Studio Code won my heart again; I am talking about Visual Studio Code 1.18 (November Update) and the Python extension v.0.8.0 (9 November 2017).
 
PyCharm vs Visual Studio Code; sorry for small VS Code icon, didn't mean any harm.
 
Figure 1: PyCharm vs Visual Studio Code; sorry for small VS Code icon, didn't mean any harm.
 
So, in this post I am going to cover a few things that will guide you in a better selection of an IDE —  in no way do I mean to make any personal or biased statement, I will only share what I feel.
 
Post will contain following sections,
  1. Performance
  2. Extensions
  3. Virtual Environment support
  4. Resource consumption
  5. Problems
Performance
 
In the performance part, I can straightaway suggest that Visual Studio Code is a winner, but that won't work out quite well. Visual Studio Code is an extremely lightweight IDE, whereas PyCharm has somewhat backend services and modules that are needed to load before the IDE can start. They can be given the benefit of the doubt, but one can easily ask for the benefits of long load time. 
 
On average, PyCharm has been reported to have an extremely slow load time. Visual Studio Code, on the other hand, is really fast and loads in less time. The modular approach of Code helps it in the performance race. Moreover, since Visual Studio Code depends heavily on extensions and add-ons, the projects and other libraries do not get loaded until they are needed to be loaded for the developers. 
 
TypeScript, Python, Java and other similar libraries load as needed. Such as, when you open a file with type for Java program, your Red Hat Java extension will kick in. Same case for C# or Python files. This gives Visual Studio Code a good ranking when it comes to performance. Lastly, the delay in rest would be a fault of the extension and how it works. 
 
If you still want to consider PyCharm for development: You are more than welcome, however, this post will help you even improve the load time of PyCharm by converting it to Power Save mode and to load less amount of resources at the startup. 
 
Extensions
 
I am not saying, only Visual Studio Code has extensions, PyCharm and almost every other IDE has some ways to extend the functionality beyond the "compile and run". The marketplace for both of the IDEs supports quite a plethora of extensions to bring more features and services. 
  • PyCharm: https://plugins.jetbrains.com/pycharm
  • Visual Studio Code: https://marketplace.visualstudio.com/vscode
Both communities have good support available. But in this case, since Visual Studio Code is a modular IDE, it can be converted to a full-featured IDE for any framework/platform/language. Whereas PyCharm is a tailored solution for Python developers, and you might be needed to download and set up other IDEs such as IntelliJ for Java, and CLion for C/C++ programming. 
 
Visual Studio Code only needs to know what type of project you are currently in and will enable those plugins making it an IDE for that project. Sounds good, right? 
 
Virtual Environment support
 
This is an interesting portion. In Python, virtual environments play a huge role in the overall development of libraries and experiments. I am not going to dig deeper into the concepts of the virtual environment, merely suggest that you need to learn some basics of Anaconda or other virtual environment creation tools for Python projects. 
 
Now, the main concept in the virtual environment is to select a different interpreter and then target that one for the current project. Unlike other installations, such as for C++ compilers or C# build systems, this is a great feature for developers targeting different projects, where a different version of Python or Python packages is needed. Anyways, the following are the steps taken in both the IDEs to work around with the virtual environments, 
 
Starting with Visual Studio Code, the IDE supports the CTRL + SHIFT + P hotkeys to configure the properties and bring out the most common settings and tasks pane for you. There you can select the "Python Interpreter" and then select the interpreter that you want to select. 
 
CTRL + SHIFT + P options.
 
Figure 2: CTRL + SHIFT + P options.
 
Selection of Python interpreter in Visual Studio Code.
 
Figure 3: Selection of Python interpreter in the Visual Studio Code.
 
Now, notice here, in PyCharm, on the other hand, the process is somehow the same, you can add the virtual environments and set their interpreters as the default. 
 
Selection of Python interpreter in PyCharm.
 
Figure 4: Selection of Python interpreter in PyCharm.
 
The main problem with these environments is that they are mainly slow. Very slow. You get same time delays in both the IDEs which is mainly due to the interpreter, Visual Studio Code and PyCharm -- so they both do not win, nor lose. For instance, have a look here, 
 
Code execution in Visual Studio Code.
 
Figure 5: Code execution in Visual Studio Code.
 
This simple task took this much time, however executing the same command with Anaconda's Python 3.6, takes the time down to almost 0.08 seconds. But that is a different story in itself. In this case, I would recommend not switching the IDE but the interpreter or the source code which makes the run take more time. 
 
Resource Consumption
 
Lastly, you need to double-check whether an IDE would be suitable to run on your machine or not. Such as, when you want to build an Android app, you are scared of what Android Studio would do to your machine, aren't you? 
 
Same is the case here, the IDEs at hand should be soft at our machines otherwise they will become a pain at the development themselves. 
 
Resource consumption of Visual Studio Code and PyCharm.
 
Figure 6: Resource consumption of Visual Studio Code and PyCharm.
 
Likewise, the programs both although serve the same purpose and as seen in the image above, they both have the same amount of projects open. They are both utilizing the CPU and RAM differently. Now it can be debated that PyCharm provides more services, such as context analysis, code analysis, and other suggestions. But Visual Studio Code's Python extension is also smart enough and in many ways faster to provide IntelliSense and the overview of what a function/object is about. 
 
In my own opinion, the Visual Studio Code is a winner in resource management. IntelliJ is bad at producing the IDE with better resource management; Android Studio, IntelliJ IDEA are just a few of such examples. Providing context analysis is not an excuse for the overuse of the memory and CPU. 
 
Problems
 
This is where we will differ in almost every sentence. Both the IDEs have a great number of extensions that can be installed, and both offer support -- Visual Studio Code has a community, working out on documentation, improvements and more. 
 
In Visual Studio Code, you have to manage everything, this can be a benefit as well as a downside. For instance, if you are a novice developer, then you are in for a surprise. You will have to install and set up a complete toolchain of the development. This stuff is also not managed in IntelliJ, you must set up a run/build configuration. So, again Visual Studio Code is better. 
 
Lastly, the only other thing to keep in mind is what your boss wants you to do. I am the boss of myself, so I go with Visual Studio Code, you might have to do what your “Prince Charming” has to suggest. 


Recommended Free Ebook
Similar Articles