-
Notifications
You must be signed in to change notification settings - Fork 3
NodeJS
- What is it?
- When and why to use it
- When and why not to use it
- Open questions
- Installation
- Start the server
- Some helpful links
NodeJS is a run-time Javascript platform. It allows you to write applications very easily and quickly in a universal language. It is primarily used to create back-end systems for a server (but NodeJS itself is not a server). It also has a command line tool.
Javascript is very good for event-based operations and long-polling applications. Long-polling allows for information to be "pushed" from the server to the client without actually pushing. The client has an open thread all the time that is listening for updates from the server, so pages can refresh without any action on the client. This is highly desirable for many applications, like chat rooms and online games. Other technologies have this capability but they are not out of the box and not as performant as NodeJS.
NodeJS is also very helpful when integrating with a front-end system that is already written in Javascript, since they would use the same language. It is very easy to learn and use, especially if you already know Javascript.
NodeJS is not very good for CPU-intensive work because all information sent to a client is on one thread. If one operation takes a long time to compute then it will hold up all of the other operations for that thread.
There are some npm packages that are not well tested or maintained, so you have to be careful or aware of which ones you are using.
Due to the abstraction of only using one thread per client, there are some restrictions in things you can do with NodeJS. Other technologies like .NET are more versatile. For example, they easily allow serialization to other languages like XML, rather than just JSON.
Does CPU-intensive work block all clients or just one? Is there one thread per client? How does NodeJS use npm?
Download the installer from NodeJS's download page.
From the nodejs folder, install the express web application framework by following these steps.
Verify 'express' is installed by running npm ls
Run node main.js
http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-node-js http://www.haneycodes.net/to-node-js-or-not-to-node-js/ http://expressjs.com/en/starter/installing.html