[TW] Node.js

  • 2,240 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,240
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
10
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Server Side Programming Using Node.JS Ana-Maria Daneliuc Bogdan GazaTW2011
  • 2. $whoarewe Students at Faculty of Computer Science ana.daneliuc@info.uaic.ro bogdan.gaza@info.uaic.roTW2011
  • 3. JavaScriptTW2011
  • 4. Java is to JavaScript Like ham is to hamsterTW2011
  • 5. JavaScript • Language of the Internet • Scripting language (interpreted) • Client side - usually run by the browser • Object oriented • Event drivenTW2011
  • 6. JavaScript • Growing in popularity • Big companies spend a lot of $$$ to improve JavaScript • Probably will become a very popular languageTW2011
  • 7. JavaScript • Until recent no clear - server side JavaScript console interpreter • Event driven on the server side also • Code sharing • All fast evented network servers were written in C/C++TW2011
  • 8. Node.JS Server Side JavaScriptTW2011
  • 9. Node.js • Event driven I/O framework • Build upon V8 engine • Server Side (includes system calls + different modules) • Intended for writing scalable network programs • Written in C/C++ and JavaScriptTW2011
  • 10. V8TW2011
  • 11. V8 JavaScript Engine • JavaScript VM used by Google Chrome • Written by one of the leading VM engineers with 20 years of building VMs - Lars Bak • The last VM written by Lars Bak - improved JavaScript 20x times.TW2011
  • 12. V8 JavaScript Engine • JavaScript to assembler • Improved garbage collector • Independent from Google Chrome • Limitations: No bytecode/No threads/No processesTW2011
  • 13. Non BlockingTW2011
  • 14. Blocking puts("Enter your name: "); var name = gets(); puts("Name: " + name);TW2011
  • 15. Non-Blocking - Node.js way puts("Enter your name: "); gets(function(name){ puts("Name: " + name); });TW2011
  • 16. Remember Select From the “Retele” Node.js Course aka explain select say about poll/epoll When receiving data (from network / disk / another source) there must be a callback Data is received Data Event Source loop CallBack User FunctionTW2011
  • 17. Non-blocking vs threadedTW2011
  • 18. Non-blocking vs threadedTW2011
  • 19. Node.js - Hello World var http = require(http); http.createServer(function (req, res) { res.writeHead(200, {Content-Type: text/plain}); res.end(Hello Worldn); }).listen(8124, "127.0.0.1"); console.log(Server running at http://127.0.0.1:8124/);TW2011
  • 20. Why use Node.js?TW2011
  • 21. Real time web applicationsTW2011
  • 22. Ajax • Asynchronous JavaScript and XML • Method to load data asynchronously • Uses XMLHttpRequest object (from JS) • Nearly real timeTW2011
  • 23. Step 1 Loading Web Page ServerTW2011
  • 24. Step 2 Done Web Page Server Ajax RequestTW2011
  • 25. Step 3 Done Web Page Server Ajax RequestTW2011
  • 26. Step 4 Done Web Page Server Ajax RequestTW2011
  • 27. Step 5 Done Web Page Server Ajax Request For another request goto step 1TW2011
  • 28. Comet Long-lived HTTP connections Reduce latency Messages are passed from the server to the client PUSHTW2011
  • 29. Step 1 Loading Web Page ServerTW2011
  • 30. Step 2 Done Web Page Server Long lived HTTPTW2011
  • 31. Step 3 Event Done Web Page Server Long lived HTTPTW2011
  • 32. Step 4 Done Web Page Server Long lived HTTPTW2011
  • 33. Step 5 Done Web Page Server Long lived HTTPTW2011
  • 34. Step 6 Done Web Page Server Long lived HTTP For another request goto step 1TW2011
  • 35. WebSockets • Use TCP sockets from the browser • Update web page 40 times / s • API is work in progress • Not supported by all the modern browsersTW2011
  • 36. Ajax vs Comet vs WebSockets Ajax Comet WebSocketsTW2011
  • 37. DEMOTW2011
  • 38. Q/ATW2011
  • 39. Thanks!TW2011