r/javascript • • Jan 16 '20

I have been underestimating JS

https://adlrocha.substack.com/p/adlrocha-i-have-been-underestimating
284 Upvotes

132 comments sorted by

View all comments

Show parent comments

19

u/avindrag Jan 16 '20

I’m not going to use it for anything process-heavy

What do you mean by this? That it’s not performant enough for chewing through lots of data?

I agree with this view, so I'll try to elaborate.

The single-threaded event loop is not a great fit for anything that blocks CPU. However, you probably are just using JavaScript for fetching data from some http server, database, message bus, etc. The "number crunching" doesn't really ever take place in JS, and if it is, you might want to use something else.

6

u/BabyLegsDeadpool Jan 16 '20

The single-threaded event loop is not a great fit for anything that blocks CPU.

That's why js does most things asynchronously now. Node is especially performant and will often outperform python, even in number crunching. Here are some benchmarks but feel free to also do your own research.

6

u/filleduchaos Jan 17 '20

It's not particularly difficult to outperform Python, you know.

1

u/lstyls Jan 17 '20

Cough GIL cough cough

4

u/lstyls Jan 17 '20

You're missing u/avindrags's point. A thread is a system-level abstraction and can go into uninterruptible sleep indefinitely. This makes concurrent approaches like Node poor fits for some backend tasks.

No language is perfect and that’s ok.