|
|
|
|
|
by j13z
4010 days ago
|
|
> Node is a tool for running Javascript on the server. Your desire to use it will stem entirely upon your desire to write javascript to perform server side tasks. Now that's often what people think of Node.js, but that's not really why Node.js is interesting. It's not just "JavaScript on the browser". Instead, you should think of Node.js more like a JavaScript binding to `libuv`, which is the C library that provides the event-driven I/O core (event loop / queue). (An example for a `libuv` binding in another language, Lua would be `luv` [1].) Reasons why JavaScript was picked for Node.js: 1) It already dealt with events due to its usage in browsers and 2) a fast existing JIT runtime, V8. To answer the original question: You might want to use Node.js if your problem is a good fit for the Reactor pattern [2]. For example, scalable network services that "mediate" between a lot of (async) I/O. Not number crunching. Nginx uses the same core concept (Reactor). [1]: https://github.com/luvit/luv [2]: https://en.wikipedia.org/wiki/Reactor_pattern |
|
> Reasons why JavaScript was picked for Node.js: 1) It already dealt with events due to its usage in browsers and 2) a fast existing JIT runtime, V8.
Well, no, the original creator of Node just wanted non-blocking IO (which the frameworks he was using did not support), and (I'm editorializing a bit here) in the grand engineering tradition of re-inventing the wheel, he decided to use Javascript with v8 to create a whole new platform, instead of using an existing platform.