loading...

re: Where does Python Shine Over Node? VIEW POST

FULL DISCUSSION
 

There is a slight apples-to-oranges comparison in the question, as Python is a language, and Node is a runtime.

You might ask to compare Python over JavaScript. There's something to be said about the advantages for beginners.

Instead, I think what you're asking is about CPython over Node. CPython is the default, reference implementation, and most-widely used runtime environment for the Python language. It has existed for much longer than Node, and one of its benefits is the ability to import C extensions. Depending on the type of things you want your code to accomplish, you may want to use a lower-level language like C to get closer to the hardware. Node has similar capabilities, but I think you're going to find a lot more of those types of extensions on pypi.org than you will with npmjs.com.

 

Interesting. Yes, of course I understand that Node is not a language, but rather the environment that one can utilize JS to complete OS-level tasks that are comparable to those that Python is often used for.

This is kind of what I suspected of Python - a more robust environment of well-tested modules for doing things that a lot of people have already wanted to do. Plus, potentially an easier implementation due to not worrying about async.

 

Hey @duhdugg ! Thanks for the great clarification on the technical details! I don't have Python experience, while mostly working on with JS/Node and PHP/Ruby world, so it was quite interesting to read that Python is not implementation itself, but CPython is.

I was wrongly assuming, for some reason, that Python is a self-hosted language, but now when I think that I heard about IronPython and CPython before, it makes sense - so those are not complier ports, but rather implementations. Should have explored this long ago, silly me. Thanks, you let me gather together those pieces in my head 😅

Continuing on the @mjcapecci question, I'm also curious about product use cases where Python as backend language would be a preferred choice over JS on the backend. I.e. the advantages of the two from the business side.

If you have experience working with both Python and Js and backend developer, would be interesting to hear for what type of project you would use Python over JS (excluding personal tastes and language proficiency).

For example, you might consider criteria like the speed of development, ecosystem size, language innate performance, maybe some other things.

Would be interesting to hear 🙂

 

I have experience in both. It usually comes down to the dependencies required, and what's already on the target environment. You might use IronPython or Jython if your environment is strictly based on .NET or Java.

There may be situations where you cannot use any outside packages (for security or other business reasons). CPython has quite a few useful things included in its standard libraries that Node doesn't have, such as libraries for CSV, XML, SQlite, and many others.

If you're interested in performance and memory usage, you should look into PyPy.

This is all really interesting stuff about target environments. I also was under the impression that, once you installed Python or enjoyed having it by default on your Mac or Linux machine, that it just simply ran in and of itself.

What are the implications on target environment when you setup a virtual environment (venv)? I wonder if this is using CPython behind the scenes.

Virtualenv supports multiple implementations, and is what you use when you want to isolate your Python environment.

Think of it like this: by default, pip install packagename is similar to npm install --global packagename. When you use virtualenv to create a new directory (called "env" for example), and then execute ./env/bin/pip install packagename, the packages are installed within that directory only (similar to how npm by default installs to ./node_modules when not using global mode).

Code of Conduct Report abuse