Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Why would I choose Python over JavaScript/Node?
7 points by vikingcaffiene on Jan 13, 2019 | hide | past | favorite | 10 comments
Bit of background: I've been coding for over 10 years professionally and consider myself to be... well, not an "expert" JavaScript developer because only a*sholes call themselves that, but a fairly advanced JavaScript developer. I'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/TypeScript/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'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?


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.


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.


> 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.


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.


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.


This. Thousands of modules required when spinning up applications. Worries about the security, side effects, bugs, maintainability of them all.

Also find the async/concurrency syntax in Python in cleaner — granted, a personal preference.


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). Another interesting example is this online community offering live backtesting of algorithmic trading strategies written in Python is Quantopian: https://www.quantopian.com/algorithms/

Some notable libraries which build on each other are scipy (http://www.scipy.org), numpy (http://www.numpy.org), pandas (http://pandas.pydata.org), scikit-learn (https://scikit-learn.org), google's tensorflow. Tools like iPython/Jupyter (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

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...

Further reading https://github.com/vinta/awesome-python https://stxnext.com/blog/2018/10/16/python-vs-nodejs-compari... https://insights.stackoverflow.com/survey/2018/#most-loved-d... https://hackernoon.com/could-pythons-popularity-outperform-j... https://www.quora.com/What-are-advantages-and-disadvantages-...


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?


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.


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




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: