Node js for beginners

Preview:

Citation preview

S ArjunS4 BCAAmrita University,Kollam

★ Javascript & the V8 Engine★ Intro to node js★ Features of Node js ★ Examples of Node js★ Node js in the industry★ How to install★ NPM★ Hello world★ Frameworks and Extensions★ Future learning★ References

What’s going to be covered?

javascript● Browser side programming● Event handling on the client side● Adding interactivity to web pages

Google v8javascript Engine

● v8 is a super fast javascript library built by google for chrome

● Compiles javascript directly into machine code instead of interpreting

● JIT(Just In Time ) compilation ● Written in c++

what the js is node?● Node.js = javascript +google v8 on the

server● Additional features for javascript to run

on the server● Handle server side events● Cross operating system compatible

What makes node better?

Event driven● Just like javascript events on the client,Node

can handle various events on the server

● Examples of server events are,file transfer,request for a page,loading content from database

Non blocking I/O● Traditional applications waits for a set code to

complete before it displays the content.This is called blocking code

● in non blocking Once the request is made we continue on to the next line of code before waiting for the time consuming request to finish

● Uses callback functions to handle non blocking code

Scalable● Node applications are highly scalable

● Horizontal scaling of servers

● Adding more servers instead of increasing the performance of each

what we can make with node?● Real time chat applications

● Upload huge amounts of data

● Data streaming applications

● Distributed ,clustered systems and embedded systems

● Applications that can handle millions of concurrent connections .

● Control Robots and drones through WLAN

who uses node.js

And many more...

A little bit of History ● Node.js was invented in 2009 by Ryan

Dahl● inspired to create Node.js after seeing a

file upload progress bar on Flickr● Opensource,sponsored by Joyent and

microsoft● Ryan was a mathematics student and

dropped out of college.

Installing node.js

● for windows download the exe https://nodejs.org/download/

● On linux just type sudo apt-get install nodejs

sudo apt-get install npm

NPM node package manager● Node package manager(NPM) is a component of

node js

● NPM fetches packages just like apt-get in ubuntu

● Packages are plugins or commonly used modules that add more functions to node.Just like beans in java

● NPM manages the dependency of the packages.

HELLO world!var http = require('http');

http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); console.log("The server just go a request"); res.write("Hello world"); res.end();}).listen(9615);

FRAMEWORKS & EXTENSIONS

● Express.js web application framework similar to python django or ruby on rails

● Cyclon.js Building WLAN/internet controlled robots and drones using node.js

● Sails.js MVC web application frameworks

● Socketstream Real Time applications .

Moving ahead!

● The best way to learn node is to use and interactive tutorial called nodeschool

● Available as an Npm package : npm install -g learnyounode

● Official node.js documentation

References● Official Node.js Documentation

● Nodeschool.io

● Wikipedia

● Node.js presentation by Gabriele Lana

● Toptal.com,code.tutsplus.com,Google developers

THANK YOU