2 ms·
I don't think this comparison is really fair at all... it seems to be cherry picked to point out what is already known to be a bad use case for node. In terms
by tracker1 10y ago
I don't think this comparison is really fair at all... it seems to be cherry picked to point out what is already known to be a bad use case for node. In terms of the multiple async calls, Promises and async functions takes care of that, not to be confused with the reference to the `async` library.
First, using clustering and memoization would improve the throughput a lot. I did something similar when adapting a JS based script library to be used in node, because I knew it would lock the main loop otherwise. Beyond this, cpu intensive work should be avoided in your service loop regardless. It's best distributed to an RPC/Worker pool.
In terms of scale, node scales as well or better than a lot of frameworks, it's only that you will usually want to use similar techniques locally as well as remote.
Another poor example is when you need millions of references in a single thread, Node will die spectacularly. That doesn't mean it shouldn't be used for many use cases, it only means that it's bad at some of them.
I find that node is great as an intermediate/translation layer... your UI talks directly to node, tightly coupled.. then node can translate against backend databases or other services as a gatekeeper for your front end. It allows you to make the data the shape that is most convenient, with the least amount of disconnect of thought and approach.
It's also pretty great for certain types of orchestration control and even in the proof of concept stages of applications. Doing a first version of almost anything I've tried in Node is usually much faster than alternative platforms. And often performs well enough to stick with it. Developer productivity is more important than absolute scale at the beginning, and if you have a plan to scale horizontally, you can do that for a while before you need to break off other optimizations.
- Scarbutt 10y agoDoing a first version of almost anything I've tried in Node is usually much faster than alternative platforms. Do you say this because of the libraries available for it? (curious, wanting to jump to node).
- tracker1 10y agoI mean faster to get up and running... development time that is. Mostly, for me, because I'm doing front end work in JS, using mostly the same tooling npm, babel (though with webpack on front end now). It's just so much faster to get going if you're developing the full stack, and already in JS heavy land anyway. Not having to context switch for the backend is huge... being able to use a document/object/json database isn't as big of a boost but still nice. On the db side, I've been using the template wrappers so that I can write a simple query and it turns it into a parameterized query returning a promise. async function getRecords(baz) { return await sql.query` SELECT a, b FROM foo WHERE foo.bar = ${baz} `; } So, I still have to think about some SQL, but still usually better than trying to twist ORMs into shape. Overall, for the past 6 years or so (since 0.8) I've been using Node pretty heavily (moving from more C# on the backend) and really haven't missed it at all. Even though the core .net and more open-source stuff has been interesting... Managed to dockerize a few trivial .Net apps using the dotnet onbuild base containers. If you're using windows, the only gotchas are you need a C++ build environment (Visual C++ 2015 Build Tools, checking all options) and Python 2.7.x in order to build any binary modules... most of which now run without issue on windows, was a much bigger problem in 0.8-0.10 ...
- FullMtlAlcoholc 10y agoAlthough the parent didn't allude to it in his reply, the network effects that the npmjs registry provides is huge and is its killer feature. In my experience, there's usually multiple, specific modules for anything you're trying to do. Case in point, I'm developing a music curation service and there are no less than 5 recently updated modules for downloading from youtube and scores of them for converting playlists from one service to another.