13. LAMP STACK 1. Order 2. Waits for the food to be cooked 3.Food is ready 4. Serve
14. Node JS 1. Order 2. Places the order with the cook 3. Immediately moves on to take the order from the next table 4. Cook notifies that the food is ready 5. Food is served
15. commonjs CommonJS is a community driven effort to standardize packaging of JavaScript libraries, known as modules. Modules written which comply to this standard provide portability between other compliant frameworks such as narwhal, and in some cases even browsers.* * Conditions Apply
20. Module/ exports This is used to package JavaScript libraries and expose the functionality to be used else where. Example: exports.pow = function (a, b) { … }
27. Simple http server /* File Name: hello-server.js */ /* Include the http module. */ var http = require('http'); /* Create a server which accepts Request - req and returns Response - res */ http.createServer(function (req, res) { /* Set the HTTP header for the response. */ res.writeHead(200, {'Content-Type': 'text/plain'}); /* End the HTTP response */ res.end('Hello World'); }).listen(9000, "127.0.0.1"); /* Print a message to indicate that the server is running. */ console.log('Server running at http://127.0.0.1:9000/');
29. Calculate power of a number exports.pow = function (a, b) { /* Check if a number is passed. */ if (isNaN (a-0) || isNaN (b-0)) { return null; } varans = 1; for (vari = 1; i <= b; i++) { ans *= a; } return ans; } Link: https://github.com/harsharv/OpenHackDay2011/blob/master/hello-server.js
Demo hello-world.js and hello-world.phpThen hello-world-2.js Actually there isn't a lot new here. But then again, there was nothing new about node either. Node uses non-blocking IO for fast scalable servers. That's been known about for years among the C community. It uses event based, single thread javascript for logic. That's exactly what the browser has. Add these together and we all see the huge splash it's made. It's the unique combination of some simple but complimentary ideas that really make these projects zing.
Re – usability of code. Give example of YUIExecute JS based on device.
Hello-server.js
Show npm search, install,ls, uninstallShow search.npmjs.orgMath.js