
Ask HN: Why would I choose Python over JavaScript/Node? - vikingcaffiene
Bit of background: I&#x27;ve been coding for over 10 years professionally and consider myself to be... well, not an &quot;expert&quot; JavaScript developer because only a*sholes call themselves that, but a fairly advanced JavaScript developer. I&#x27;ve been using Node nearly since its beginning and have gotten hip to TypeScript and love it. I have experience with other languages (C#, PHP, and Elixir) as well but my goto is always the JavaScript&#x2F;TypeScript&#x2F;Node unless I have a specific reason not to. Python is getting ever more popular and hireable so I decided that it was time to learn it this year. I&#x27;ve been digging into it and... well its not that I find working with it bad its just _weird_. Its got all the normal language things but seems like its doing them differently just for the sake of it? The weird `__function_name__` stuff, the way inheritance works, `self` instead of `this`. I dunno I am following along and learning the language fine but I guess I want to understand why people are gravitating to this language. Whats its appeal Can someone sell me on Python?
======
mneil
I'm kind of in the same boat. Here's my opinion. Python has many numeric
types. That makes it well suited to machine learning and data science which
are hot right now plus the language is simple enough to pick up. That's lead
to an increase in popularity.

My other opinion is that python 2 is losing ground and more support for python
3 is here. That's making it easier to get started. Pipenv has simplified
virtual environment and python is very stable.

There are more developers today than there were yesterday. Just because a
language is more popular today doesn't mean other languages are used less. It
just means more people are starting with one language over another. Again, my
opinion.

------
bradknowles
So, how about the reverse — you try to sell us on using JavaScript or node
instead of python.

Please make sure that you include an explanation of why it’s considered normal
for a node application to have a thousand dependencies or more.

~~~
vikingcaffiene
> Please make sure that you include an explanation of why it’s considered
> normal for a node application to have a thousand dependencies or more.

Don't be a dick. I wasn't trying to flame Python or turn this into an us vs
them type of debate. I was legit asking a question about a technology choice
people are making.

~~~
bradknowles
Its a legitimate question. If you want to compare Python and Node, then you
have to address the elephant in the room.

Or, at least one of the elephants in the room.

~~~
vikingcaffiene
It was at very least sarcastic if not outright hostile in tone. Perhaps you
didn't mean it that way but it's hard to really read it any other way IMO.

If you want to have a conversation about the merits of Node and the JavaScript
ecosystem at large. I am happy to do so but only if we keep things civil and
constructive. Furthermore, I am not trying to have a Node vs Python debate
here. I was asking about the merits of Python and why people are choosing it.
There's clearly something there so I wanted to know because it goes about
doing things so differently than I am used to. If you look at some of the
other comments, you'll see that's exactly what I got.

So with that hopefully cleared up, are you wanting me to discuss why I prefer
the JavaScript/Node stack over some of the other languages I've worked with?
Happy to give a rundown and answer questions. The node_modules thing for
instance:

Yes that is problematic although less so than it used to be. The latest
versions of NPM and Yarn do a great job of resolving the dependency tree in a
much saner and more predictable way with lock files and such which means you
get a flatter tree with no duplicate deps. That still leaves us with a giant
gob of code. This is more problematic on the front end with an SPA so lets use
that. Obviously you don't want to load crap loads of JS on the page that you
don't need so you leverage things like lazy module loading, tree shaking
(literally discarding dead unused code in your bundle), and code splitting.
Tools like Babel, Webpack, NextJS, and Parcel are really good at that kind of
thing. There's also server side rendering where you hydrate your app with
everything it needs on page load for a lighting fast first paint. The point is
that all that stuff in your node_modules folder doesn't necessarily get loaded
into your final app. I have been seeing some really interesting work coming
from the NPM team recently where they are working on way to work with no
node_modules folder at all! Literally JIT install from your import statements.

If there's anything else you want to discuss, a question or something, fire
away.

------
0xcebe
Short answer: for an experienced JS developer, choose Python over JS if your
application falls into Python’s areas of excellence (data science/ML, system
automation, graphic pipelines, gaming engines) and if you have the time to
learn it (Python is generally easier to learn than JS). For other applications
like web development, it’s likely not worth switching to Python for an
experienced JS developer. Raw curiosity and experimentation is always a good
reason, Python is the 3rd most loved language by developers according to
StackOverflow.

——

Long answer

From experience the python ecosystem is great when it comes to analyzing data,
data science, machine learning.

Previously the alternatives for data science were R/Matlab/Octave which are
languages designed by/for mathematicians primarily - while python is a
general-purpose language. These languages tend to perform slower than Python.
A more recent alternative is Julia,
[https://en.wikipedia.org/wiki/Julia_(programming_language)](https://en.wikipedia.org/wiki/Julia_\(programming_language\)).
Another interesting example is this online community offering live backtesting
of algorithmic trading strategies written in Python is Quantopian:
[https://www.quantopian.com/algorithms/](https://www.quantopian.com/algorithms/)

Some notable libraries which build on each other are scipy
([http://www.scipy.org](http://www.scipy.org)), numpy
([http://www.numpy.org](http://www.numpy.org)), pandas
([http://pandas.pydata.org](http://pandas.pydata.org)), scikit-learn
([https://scikit-learn.org](https://scikit-learn.org)), google's tensorflow.
Tools like iPython/Jupyter ([https://ipython.org](https://ipython.org)) act
somewhat like an IDE in the data analyst's workflow. It

Other popular use cases for python: system programming and automation as an
alternative to shell/perl scripts because the python interpreter ships with
most linux distributions by default while other scripting language do not.
This use case is especially popular at Google where Python's creator and
"benevolent dictator for life" Guido van Rossum had been working for 7 years.
Examples of such applications built in python include Ansible, Docker-compose.

Yet another application where Python is popular is gaming engines (Pygame,
Panda3D). Python is also the de-facto language for graphic pipelines and
interoperability between 3D applications in the media and entertainment
industry. It is supported directly in the Unreal Engine and Maya.

According to this Quora page, a Google Engineer uses python for
build/test/deployment automation, some monitoring and service configuration
tasks, Tensorflow configuration and results analysis. Other answers mention
python used in much of the Youtube codebase. [https://www.quora.com/What-is-
Python-used-for-at-Google](https://www.quora.com/What-is-Python-used-for-at-
Google)

Python is also a good option to write a REST API server really quickly using
the flask-restful library. [https://codeburst.io/this-is-how-easy-it-is-to-
create-a-rest...](https://codeburst.io/this-is-how-easy-it-is-to-create-a-
rest-api-8a25122ab1f3)

Further reading [https://github.com/vinta/awesome-
python](https://github.com/vinta/awesome-python)
[https://stxnext.com/blog/2018/10/16/python-vs-nodejs-
compari...](https://stxnext.com/blog/2018/10/16/python-vs-nodejs-comparison/)
[https://insights.stackoverflow.com/survey/2018/#most-
loved-d...](https://insights.stackoverflow.com/survey/2018/#most-loved-
dreaded-and-wanted) [https://hackernoon.com/could-pythons-popularity-
outperform-j...](https://hackernoon.com/could-pythons-popularity-outperform-
javascript-in-the-next-five-years-abed4e307224) [https://www.quora.com/What-
are-advantages-and-disadvantages-...](https://www.quora.com/What-are-
advantages-and-disadvantages-of-Python)

~~~
vikingcaffiene
Thank you very much for taking the time to answer in such detail. It does
confirm my suspicion that most of my use cases are already adequately covered
by JS/TS/Node and that there's not some killer hidden feature that I am
missing.

The links you sent in particular answered a lot of questions for me. Seems
like one of the biggest draws (for me at least) is that python is slower to
change over time. That cannot be understated and is my biggest frustration
with the JavaScript world. That is, the unending need to learn the new
"Obviously Best Way" to do things every 12 months or so. It gets exhausting.

I'm naturally curious so I'll keep learning python. Can't hurt right?

~~~
vanous
Not an expert but would recommend you to look at pyenv with virtualenv from
the start. This allows you to use python3 version of your choice in virtual
environment based say per project etc. Obviously, this landscape has been
changing rapidly lately and other people might recommend different tools, but
for manual (or automated) server deployment I like this - I can test new
versions of libraries and python (3.7.2 ;) and switch between them super
easily without affecting/breaking each other.

~~~
vikingcaffiene
Yeah I installed pyenv first thing. Made things a lot easier.

