• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to node.js
 

Introduction to node.js

on

  • 3,394 views

 

Statistics

Views

Total Views
3,394
Views on SlideShare
3,358
Embed Views
36

Actions

Likes
2
Downloads
71
Comments
0

1 Embed 36

http://www.petari.com 36

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduction to node.js Introduction to node.js Presentation Transcript

    • Introduction to Node.js By Arun Kumar Arjunan, Product Architect, Chronus
    • AGENDA• About Node.js• Programming in Node.js• Web Frameworks• Node.js internals• Popularity of Node.js• Downside of Node.js
    • ABOUT NODE.JSWhat isNode.js?
    • ABOUT NODE.JS Node.jsApplications
    • node.js KO
    • NIDE
    • Chess@home
    • GITJSGitJS is a pure JavaScript implementationOf Git.Example Commands:• git.js log• git.js branch• git.js show SHA
    • NODECHAT
    • DEFINITION Node.js is an event-driven I/O server-sideJavaScript environment
    • AGENDA• About Node.js Programming in Node.js• Web Frameworks• Node.js internals• Popularity of Node.js• Downside of Node.js
    • HELLO WORLD PROGRAMNode.JS is a command line tool $ node hello-console.js
    • HTTP SERVER
    • FILE SYSTEM
    • OTHER LIBRARIES• Timers • DNS• Events • REPL• Buffers • Child Processes• Streams • ZLIB• Crypto • OS• TLS/SSL
    • NODE IS EVENT DRIVENDid you notice that the previous examples use Event Driven technique?
    • NODE IS EVENT DRIVEN
    • NODE IS EVENT DRIVEN
    • NODE IS EVENT DRIVEN$ ab –n 200 -c 50 http://localhost:8080/
    • NOW IN RUBY require rubygems require mongrel class HelloWorldHandler < Mongrel::HttpHandler def process(request, response) sleep a2 response.start(200) do |head,out| head["Content-Type"] = "text/plain" out.write(“Hello World”) end end end h = Mongrel::HttpServer.new("127.0.0.1", "1337") h.register("/", HelloWorldHandler.new) h.run.join$ ab –n 200 -c 50 http://localhost:1337/
    • EVENT DRIVEN VS THREADINGLets compare Event Driven Programming& Thread based programming!!! • Some theory proves Threading model is better • Some proves Event Driven Programming is better
    • EVENT DRIVEN VS THREADINGLets take an example that is relevant to us!!!
    • APACHE VS NGINX
    • APACHE VS NGINX
    • APACHE VS NGINXThe difference?Apache uses one thread perconnection.NGINX doesn’t use threads. It usesan event loop
    • Disadvantages of Threading• Context switching is not free• Execution stacks take up memory• For massive concurrency, cannot use an OS thread for each connection.
    • AGENDA• About Node.js• Programming in Node.js Web Frameworks• Node.js internals• Popularity of Node.js• Downside of Node.js
    • NODE.JS COMMUNITY Node.jshas excellent community
    • NODE PACKAGE MANAGER NPMIts like bundler for Ruby Gems
    • AROUND 60 TEMPLATE ENGINESasyncEJS, bake, bind-js, blue, CoffeeKup, combyne.js,doT.js, dust, Eco, ejs, haml.js, haml-js, jshtml, jqtpl,Jade, jazz, JinJS, JSON Template, jm, jsdom, less.js,Liquor, minimal.js, Mu, nTPL, nodejs-meta-templates,normal-template, nun, node.magic_dom, node-template,node-properties, Parrot, PURE, stencil, Node-T, Swig,Templ8, template.node.js, tmpl-node, TwigJS, weld
    • WEB FRAMWEORKS1. Geddy2. ExpressJS3. RailwayJS
    • RAILWAYJSQuick guide to RailwayJS Its like Rails itself
    • ROUTES IN RAILWAYJS
    • CONTROLLERS IN RAILWAYJS
    • MODELS IN RAILWAYJS
    • AGENDA• About Node.js• Programming in Node.js• Web Frameworks• Node.js Internals• Popularity of Node.js• Downside of Node.js
    • NODE.JS ARCHITECTURE
    • ABOUT V8• V8 team is led by Lars Bak• Lars Bak was the technical lead behind HotSpot (Sun’s Java VM).• HotSpot improved Java’s performance 20x times• Before HotSpot Lars Bak worked on a Smalltalk VM• V8 uses hidden classes
    • UNDERSTANDING V8 Lets try tounderstand V8
    • UNDERSTANDING V8• It is used to run JavaScript• Can be embedded into any application• Can expose C methods & Objects using JS interface
    • USING V8
    • USING V8String::New(“a = 1; b = 2; a + b”)$ ./hello-worldString::New(ARGV[1])$./hello-world “a = 1; b = 2; a + b”String::New(fread(ARGV[1]))$./hello-world hello-world.js
    • NODE.JS ADVANTAGESSo Node.Js is nothing but a set of libraries using V8 engine
    • AGENDA• About Node.js• Programming in Node.js• Web Frameworks• Node.js Internals• Popularity of Node.js• Downside of Node.js
    • NODE.JS ADVANTAGES• Server side Javascript• Javascript is dynamic• Event based• Learning curve is less• Suited for event driven programming• Uses V8 which relatively faster• Uses CommonJS module spec
    • NODE.JS ADVANTAGESIs the server side JavaScriptprogramming new?
    • SERVER SIDE JS FRAMEWORKS• Helma - Rhino• AppJet - Rhino• Aptana Jaxer - SpiderMonkey• CouchDB - SpiderMonkey
    • NODE.JS ADVANTAGES Is the Event Drivenprogramming new?
    • EVENT DRIVEN PROGRAMMING LANGUAGES• E Programming language• Event Driven MVC Framework for SmallTalk• AmbientTalk
    • Similar Frameworks• Event Machine for Ruby• Libevent for C• Twisted for Python
    • ConclusionSo why is Node.js so popular?
    • ConclusionI think its becauseRyan Dhal put cool things together!!!
    • AGENDA• About Node.js• Programming in Node.js• Web Frameworks• Node.js Internals• Popularity of Node.js• Downside of Node.js
    • NODE.JS COMPLAINTS• Programmers are used to synchronous code• Exceptions are hard to handle• Difficult to debug• Most importantly it is not matured yet• Doesn’t utilize multi-core CPU
    • ConclusionFUTURE OF NODE.JS ???