Learning to build
Scoreboard: Node.js 1, Python 0
Installing Node.js is a simple task, whether you use macOS, Windows, or Linux. For most users, it’s as simple as downloading an executable and double-clicking.
Installing Python is often more difficult. Python 2 comes pre-installed on macOS, but you shouldn’t use the installed version for your coding because it’s used by system libraries. Instead, you’ll need to install a new version alongside the existing version. Installing Python on Windowscan also be somewhat tricky. Many tutorials recommend installing a package manager like Chocolatey before getting started, which can be a bit of extra work. If you’re working on Linux, installing Python is no sweat.
Node.js is easier to use out of the box on two out of three platforms, so it scores another point here.
Scoreboard: Node.js 2, Python 0
Library management is a category in which both languages excel. Pip (which stands for “Pip installs Python”) provides tremendous library management for Python. The maintainers of Pip make sure that it’s fast, stable, and easy to learn in just a few minutes.
NPM (the Node Package Manager) provides package management for Node.js. NPM is one of the largest repositories of software libraries in the world. Like Pip, NPM is fast, well-documented, and a breeze to learn in an afternoon or less.
As your project grows, dependency counts usually grow as well. A good dependency manager saves hours of time and countless headaches.NPM and Pip are two of the best. Both languages score a point in this category.
Scoreboard: Node.js 3, Python 1
If you only ever work on one project, environment management isn’t a concern. Most developers find that between work and personal projects, they need to support more than one code repository. When working with a package manager like Pip or NPM, managing more than one codebase can cause serious headaches. What if the version of a library you use for work is different from the version of a library that you use for your personal website? This is where environment managers come into play.
The lead environment manager for Python is virtualenv. Virtualenv is a powerful tool that can manage different Python projects, up to and including installing different versions of the Python interpreter itself. Virtualenv is one of the original environment managers, and it’s been actively maintained for more than a decade. As you’d expect, it’s rock-solid and very easy to learn.
Node.js has a similar tool to Virtualenv called nodeenv. Nodeenv is developed and supported by the same people who make Pip, which is a great recommendation for a software package. Nodeenv comes with a big caveat, though: you need to install Python to make it work. If you’re deciding on Node.js to avoid having to install Python on your computer, using nodeenv would defeat the whole purpose.
Scoreboard: Node.js 3, Python 2
Scoreboard: Node.js 3, Python 3
Asking which programming language is faster is a dangerous exercise on the internet! In this comparison, you’ll find little dissension, though. Node.js web apps are mostly faster than Python web apps. The reason is related to that event-driven architecture we talked about in the last section. If you haven’t read the link in the previous section (here it is again so you don’t have to scroll back), you should do that now to truly understand why. Node.js code doesn’t spend as much time waiting on network requests and database queries. This means that it does more work in less time, which means faster server responses and page renders.
Python does have the ability to build asynchronous, event-driven web apps. Modules like asyncio make writing asynchronous Python code similar to writing that kind of code in Node.js. Python doesn’t win a point here, though, because most major Python frameworks don’t have this built in.
Finally, it’s important to remember that just because you choose one language or framework, you’re not guaranteed a fast web app. Monitoring the real-world performance of your app through a tool like Retrace is critical to understanding how your app is actually performing for your users.
Scoreboard: Node.js 4, Python 3
Looking at the scoreboard, Node.js holds a slight lead over Python, and I think that’s accurate. In 2019, both Node.js and Python are attractive options for building a new web app. As someone who’s just learning, you may find that Node.js has a pile of excellent frameworks to choose from. Python has similarly excellent frameworks in Django and Flask. Neither choice is a wrong one, and both languages have thriving communities. If it were up to me to choose which language I’d use to start a new web project, I would lean toward Node.js. But the most important thing is to start turning your dream web app into reality today. Get out there and get coding!
If you would like to be a guest contributor to the Stackify blog please reach out to [email protected]