Post on 21-Mar-2017
Node.js Kick Start First Node Community Meet-Up in Chennai
What Node.js is not?
• not a programming language• not just a JavaScript Engine
What Node.js actually is?
• server-side web application development framework• It is also a javascript engine
Where to use Node.js?It is not advisable to use Node.js for CPU intensive applications.Why not? Let’s learn..
Node.js Background
Brief History of Node.js
• Ryan Dahl - 2009-2012• Isaac Schlueter - 2012-2014• Timothy J Fontaine - 2014 - 2015• Fedor Indutny - io.js 2015• io.js & Node.js merged in 2015• First merged release was v4.0.0 in 2015
How the system works?• open-source• open-governance
Node.js Foundation
• Board of Directors• TSC
Versions
• Strictly semver• LTS - v4.4.3• Current - v6.0.0
Features of Node.js
• Event Driven• Non-blocking I/O• Single Threaded but highly scalable
Building Blocks of Node.js
Writing asynchronous code is different
Typical Approach
var conn = getDbConnection(connectionString);var stmt = conn.createStatement();var results = stmt.executeQuery(sqlQuery);for (var i = 0; i < results.length; i++) { // print results[i];}
An asynchronous non-blocking approach
getDbConnection(connectionString, function (err, conn) { // callback
if (err) { //Handler errors } conn.createStatement(function (error, stmt) {
//callback if(error) { //Handle errors } var results = stmt.executeQuerty(sqlQuery); results.on('row', function (result) {
// Event emitted for the rows //print result }); });});
Writing asynchronous code is different
What is NPM?
• package manager (like maven, sbt)• Isaac Schlueter - npm, Inc• package.json• Custom modules
Let’s see them in Action…
Thank You!