I'm rewriting my server and deciding between using Node.js and Python.
I prefer Javascript (as I'm extremely well versed in it) but this article is giving me pause. I'm curious if anyone has had any problems but also, I'm curious if there are any platform related virtues to one over the other.
Specifically, do either of them not-support/limit/excel-at
I don't want to start an argument about the virtues of PHP or .Net, I have made a definitive decision to move to either Python or Node.js and was totally settled on Node.js, until I read the above article, so, really, I'm just looking for specific problems/virtues that people have had with these two tools.
Thanks in advance.
There are two issues here:
Unlike what the article suggests a single threaded non blocking IO model isn't bad in principle. Personally I like this model a lot, since it removes the complexities of multi-threading, while still working on a shared memory model.
Another advantage of this model is that because you don't need a thread per request, you can have many concurrent open requests.
One disadvantage is that without language support, you need to explicitly queue continuations, instead of writing the code in a simple imperative manner. C#5 attacks this problem with its async-await feature, and I wouldn't be surprised if node.js offered something similar in the future.
The article mainly talks about the second disadvantage: If you block the main thread, you block the whole server.
One of his examples is simply abuse: He implements a busy wait, instead of subscribing to an event. With correct programming this simply shouldn't happen.
The other example has more of a point: If you have CPU intensive calculations, you better not do them on the main thread. The simple solution to this is spinning of a worker thread, that does the calculation without touching memory used by the main thread. And once it's done it calls a callback on the main thread. Not sure if node.js offers this though. But since many server applications aren't CPU bound, this often isn't a problem at all.
In general that article is very low quality, and tells more about the author than about node.js. You shouldn't let it influence your decision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With