Why use Node.js?
You may hear people saying that node.js is not good, poor performance, and not for enterprise application. Before answering this question, we better to have a look to the below pros and cons. Then, we can conclude what kind of application is good to build with node.js, and what is not.
- With build-in package management tool – NPM, you can easily add NPM modules to your node.js environment.
- With Express or other framework, you can build Restful application easily.
- Good for audio / video streaming, because node.js has fast, non-blocking and asynchronous I/O.
- Good for real-time app.
- Not good if the request is CPU intensive, because it will block the entire system.
- Not good for reporting
- Not good for calculating
- It is single-thread, can’t handle concurrency, or multi-users. NOT 100% true, node.js has one single thread listening to your request for your program.
- If the request is non-CPU intensive, this single thread will execute the job and return.
- If the request is long running I/O request, this single thread will pass to the pool of native C++ threads to handle the request.
- Too many callbacks. Because asynchronous is a nature of Node.js. However, most of our applications’ functions may need to be synchronous, especially interacting with users. So, we may need to define our function with callback, in order to make it to be synchronous.
So, we can conclude:
|Simple web page
You can follow this blog in order to buildup some examples with node.js.