4 ms·
Python feels noticeably slower than Node.js, particularly when running scripts with large amounts of imports. I now pretty much always use JavaScript for, well,
by tuckerconnelly 6y ago
Python feels noticeably slower than Node.js, particularly when running scripts with large amounts of imports. I now pretty much always use JavaScript for, well, scripting. Not sure why Python and Ruby are considered go-tos there.
- nullcat 6y agoPython as an implementation is slow but python as a language is much better designed then javascript. That is the main reason why they are gotos.
- offtop5 6y agoEh, when it comes to scripting, performance is almost never a concern. Different tools are best for different jobs, for example if you need to run some basic NLP jobs pythons going to be much better.
- wongarsu 6y agoPython gives you better escape hatches for typical compute-heavy work (lots of libraries use C under the hood), and Python has a better multi-threading story than Node.js. But I guess the biggest differentiators are really the ecosystems and standard libraries. Node.js is certainly catching up, but Python has generally a better selection of high-quality libraries for tasks beyond the web.
- brrrrrm 6y agoI believe libraries like v8pp are helping to shrink the gap with C library integration.
- tuckerconnelly 6y agoLack of library support is probably the most valid reason here. Most of the other reasons people have posted seem like opinions on ergonomics. I think those held true 10 years ago, but modern JavaScript feels very minimal and lisp-y and is more enjoyable to program with than Python IMO. What libraries or escape hatches to you actually use in your daily work that are exclusive to Python? The ones I'm familiar with would probably be OpenCV and the whole machine-learning family of libraries (sci-kit, spacy, tensorflow, etc).
- haswell 6y agoI’ve been scripting in Python since 2003. Node wasn’t mature/viable at the time. Edit: didn’t exist at the time! Python is my go-to because I know the ecosystem well and can go from zero to done with minimal effort and research. Node has since (come into existence) and matured, and while it may be better/faster in some situations now, I haven’t encountered a project that has compelled me to switch. I suspect the answer to your question boils down to a combination of: familiarity, preference, individual productivity, and pragmatism. This will likely shift over time.
- franciscop 6y agoNode.js was created in 2009, so it wasn't even born in 2003: https://en.wikipedia.org/wiki/Node.js https://en.wikipedia.org/wiki/Node.js
- haswell 6y agoGood catch. Brain fart on my part.
- Sohcahtoa82 6y agoNode.js not existing probably contributed significantly to its non-viability in 2003. ;-)
- arcturus17 6y agoBecause not all scripting has strict performance requirements, and as much as I love JavaScript, Python blows it out of the water in scripting ergonomics and semantics IMO. Opening / reading / writing files, parsing args, making HTTP requests, etc. which are extremely common scripting operations are easier with Python, and the end result tends to be much more succinct thanks to its syntax (this applies to all Python code compared to JavaScript, but I'd argue it's especially valuable in shorter scripts).
- rootusrootus 6y agoFor a lot of workloads, performance is less important than maintainability. Python's cultural and technical adherence to an ideal code structure makes it a good candidate for long-haul code where CPU-bound performance isn't going to be a factor. IMO the opposite end of that particular scale is Perl.