Why chose to develop in Node? What are the pros and the cons? What was it designed for?
Node was designed for web application development in mind, specifically aiming to process non-intensive CPU process asynchronously and fast. Knowing when to use Node and when not to use Node depends on context; to make this easier, below is a list of pros and cons to using Node.
Pro's:
- One language:
- Node is written in Javascript which means that, assuming your already using javascript for your frontend, you would only ever have one language to work with. That makes it easier for developers to write more code and focus on logic rather than language syntax. This is especially true for companies that maybe using JS, PHP, C or a mix of multiple languages.
- Its fast.
- V8: The V8 engine developed and maintained by Google compiles javascript, using C++, into machine code, which makes it incredibly fast. Also,
- The Event Loop: As I've written in a previous post, the event loop is what provides javascript is awesome power in conjunction with the V8 engine. The event loop is a single thread that performs I/O operations asynchronously by handing async operations to the event loop with a callback so it can run the rest of the code. Once the async operation completes, the callback is called.
- Network connections, filesystems, and database queries run very quickly in javascript due to the event loop and v8 compilation.
- NPM
- NPM is the largest package manager on the web and is entirely open-sourced. With a large, thriving community supporting it, the reliability of node's package manager is a sure thing for many years to come.
- Additionally, many of these modules are made in a plug-and-play sort of manner and are incredibly performant - one of the many benefits of having the support of a large online community for an open sourced platform. (EG: bluebird, socket.io, etc)
- Its based on JavaScript
- This one isn't so much to do with Node as to what language its built for. Javascript itself is not as opinionated as other languages, which can be a good thing and can be a bad thing. If your looking to create a safety-critical system that would be disastrous if there were any bugs, then yeah, maybe look for a more opinionated language, like TypeScript, with more built-in testing interfaces.
- CPU heavy requests
- Because Node is single-threaded, CPU intensive requests are not as ideal (unless a significant portion of the request can be run asynchronously, but this is not always the case).
- The number of modules
- NPM is flooded with many different modules, which can be a good thing and, again, a bad thing. The bad thing about having many different modules is that you can have 2 separate apps that do the same exact thing but built very differently with different modules. This can make it difficult to find one answer to one problem with one type of module. However, this is minor since there are market-recommended modules that are more used than others, thereby consolidating a good portion of FAQ that are easy to lookup.
References:
http://blog.modulus.io/top-10-reasons-to-use-node
http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-node-js?rq=1