Choosing a code editor for Python
A comparison between PyCharm, VS Code, and JupyterLab for Python programming.
As a Data engineer, ML engineer or Python software engineer, one of the most important tools in your arsenal is the code editor of your choice. The code editor you choose can greatly impact your productivity and overall development experience.
In this blog, based on my experience, I’ll be comparing three popular Python code editors: PyCharm, Visual Studio (VS) Code, and JupyterLab.
How I started
When I began my career as a Data Scientist, I started coding in Python with using a combination of Jupyter notebooks and Spyder. Jupyter notebooks are great for data exploration, visualisation, and sharing code with others. It allows you to create and share documents that contain live code, equations, visualisations, and narrative text. On the other hand, Spyder is a powerful scientific environment written in Python and designed specifically for scientific computing. It’s a great tool if you’re replacing tools like Matlab or R Studio with Python.
However, as projects grew in complexity, I found myself needing a more robust Integrated Development Environment (IDE) that offers features such as code completion, debugging, linting and version control integration. This led me to discover PyCharm.
PyCharm: The one stop shop
PyCharm is a powerful and feature-rich IDE developed by JetBrains. It offers a wide range of tools and features that make Python development a pleasant experience. Some of its key features include:
All-in-one editor: PyCharm providers a very complete code editor. Among others it contain intelligent code completion, out-of-box Python interpreter (venv) management, automatic refactoring and integration with popular libraries (Django, Flask, etc).
Extensive native functionality: PyCharm has a built-in debugger that allows you to step through your code, set breakpoints, and inspect variables. In addition it offers integrated version control tooling and tooling which makes testing and profiling much easier.
Database, k8s, collaborative support (Professional edition): PyCharm provides a SQL database editor and allows you to execute queries directly from the IDE. It also offers integrations like collaborative editing and Kubernetes. It does come with a price tag though as all of this is part of the Professional edition.
I used PyCharm for many years and was quite happy with it. However, as I started exploring other languages and frameworks (e.g. front-end React, Javascript), I began to notice the flaws of PyCharm. For example, while PyCharm also offers supports for different languages you would usually either have to pay for the Professional version or use another IDE. This led me to discover VS Code.
VS Code: Lightweight and extensible
VS Code is a lightweight, yet powerful, code editor developed by Microsoft. It is designed to be highly customisable and extensible, allowing developers to add new features and functionality as needed. Some of its key features include:
Extensibility: VS Code has a vast library of extensions that can be easily installed to add new features and languages. For example adding AI code generation to VS Code is as easy as adding an extension. It also means that paid functionality in PyCharm can be obtained in VS Code for free.
Run it how and where you like: VS Code runs on Windows, macOS, and Linux, making it a versatile choice for developers on any platform. There’s even a VS Code server service you can use to run VS Code as a centralised service.
Light-weight: VS Code is much more light weight than an editor like PyCharm, which gives it a smooth user experience. By default it is more comparable to an editor like Sublime or Atom. Microsoft does offer their own extensions which fill the functionality gap. This gives you full control over what you’d like to use without making the application unnecessarily heavy.
Debugging, git and integrated terminal: VS Code offers integrated terminals, git integrations and debugging tools. This makes it a complete IDE offering that rivals PyCharms capabilities. However, given that some of these capabilities need extensions it might feel less like one unified solution.
As mentioned before I’ve began using VS Code more and more. Anyone that is newly picking up an IDE I recommend VS Code. It does have a steeper learning curve when comparing to alternatives. Nevertheless, the extensibility and customisability is unrivaled.
JupyterLab: A flexible web-based editor
JupyterLab started as a next-generation web-based interface for Jupyter notebooks. It’s the natural evolution of the older JupyterHub servers. It offers a more flexible and customisable environment primarily for data science and data analysis. Some of its key features include:
Flexible layout: JupyterLab allows you to arrange multiple notebooks, text editors, terminals, and other components side-by-side in a flexible layout.
Extensibility: Similar to VS Code, JupyterLab is highly extensible. It allows you to add new features and functionality through extensions. This makes that it can bridge gaps to other tools like VS Code and PyCharm, but in some cases not fully (e.g. debugging).
Interactive widgets: JupyterLab supports interactive widgets, which allow you to create rich, interactive visualizations directly within your notebooks.
Support for other languages and files: JupyterLab’s origins lie with Jupyter notebooks. This is both a blessing and a curse. By design it is less suitable for complex projects with many file, file types and languages. Extensive Python projects are difficult to control using JupyterLab alone.
JupyterLab is a great place to build prototypes and experiment. However, when it comes to managing complex projects it’s beaten by alternatives like PyCharm and VS Code.
Honourable mentions
The editors which I’ve compared are picked based on my own experience. I’ve seen these come by at different places but at each company it differed based on the project and/or role which editor was picked.
There are however many more editors to choose from. If you’re looking for editors that are more vanilla, picking Sublime or Atom might be good choices. If you’re looking for a local option that beats JupyterLab in terms of interactivity, then DataSpell might be worth looking into. If you just want to use a hosted tool without the hassle of setting up anything, look into Google Colab.
Conclusion
In conclusion, the best code editor for Python depends on your specific needs and preferences. If you’re looking for an out-of-the-box feature-rich IDE with a focus on Python development, PyCharm is an excellent choice. If you prefer a lightweight, extensible editor, highly customisable editor VS Code might be the perfect fit. And if you’re primarily working with Jupyter notebooks and need a more flexible and customizable interface, JupyterLab is definitely worth considering.
Ultimately, the key is to find the tool that works best for you and your projects. If you’re already invested into an ecosystem it’s perfectly valid to stick with something.