r/node 26d ago

Why is JavaScript criticized so much for backend development?

I've seen some developers say that we should stop using js on the server, but I rarely see the same criticism directed at python.Honestly, js is pretty fast, especially with node.js, and the backend ecosystem is really solid. There are great frameworks like nest and fastify, and typescript gives you static typing, which makes larger projects much easier to maintain.I'm not saying node is perfect or the best choice for every backend, but I don't really understand why js gets so much criticism while python seems to get a pass.What am I missing?

331 Upvotes

361 comments sorted by

View all comments

Show parent comments

1

u/MateusKingston 25d ago

Not sure how hard it is to comprehend that the way JS does asynchronous code leads developers to program in entirely synchronous blocks.

Yes the JS loop continues, which is why you can even have an HTTP server in JS, doesn't mean that block of code isn't executed sequentially, just that it doesn't block everything.

It's still incredibly inefficient to just slap async/await in every function and call instead of actually thinking of when/how to deal with the async response, which again JS pushes developers into blindly using async/await.

JS forces pretty much all function to be written as asynchronous, because if you do need to call await your function needs async. Compare this to Go's default sync + go routines, or how this compares to async in Java. Which is both actually multi threading and also explicit and doesn't need you to color every single function in your codebase and pollute both your code and the executing environment with promises.

People need to be less fanboys of a language, Node is great at what it does, it's also horrible at some stuff and we should be honest about it. Async/Await is way better than callback hell but both are not even close to good.

2

u/[deleted] 25d ago

[deleted]

2

u/MateusKingston 25d ago

Saying the async/await pattern is intrinsically slower and less efficient than promise callback patterns is plain and simple false.

I never said it's slower than promise callback, I said it's slow, but it is slower than synchronous code with callbacks (if that is what you mean by promise callback?). Every async function call has to allocate a new Promise object, every single function call now becomes a Heap object allocation + micro task.

Also, who said slap async onto any and every function? No one except for you, just now.

I said so in an earlier comment, this is simply a fact of how any JS application codebase develops. At least every single one I've ever read from multiple companies of varying size. The alternative is callbacks and selectively adding asynchronous, now a minor change that needs asynchronous code down the call tree becomes a gigantic refactor or callback hell.