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!!!
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
USING V8String::New(“a = 1; b = 2; a + b”)$ ./hello-worldString::New(ARGV)$./hello-world “a = 1; b = 2; a + b”String::New(fread(ARGV))$./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
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