Your SlideShare is downloading. ×
0
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Nodejs - A-quick-tour-v3

9,645

Published on

1 Comment
6 Likes
Statistics
Notes
  • *CLICK the LINK to keep updated on all the latest Mods/Glitches*
    adf.ly\QBJDM
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
9,645
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
70
Comments
1
Likes
6
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

Transcript

  • 1. node.js A quick tour (V3) 07.10.2010
  • 2. About Contributor Co-founder Felix Geisendörfer formidable node.js driver node.js file uploads
  • 3. Audience?
  • 4. JavaScript?
  • 5. What is node?
  • 6. Server side JavaScript $ git clone git://github.com/ry/node.git $ cd node $ ./configure $ make install
  • 7. Server side JavaScript $ cat test.js console.log('Hello World'); $ node test.js Hello World
  • 8. Server side JavaScript $ node > console.log('Hello World'); Hello World >
  • 9. Ingredients libeio libev c-ares V8 http_parser
  • 10. Philosophy • Just enough core-library to do I/O • Non-blocking • Close to the underlaying system calls
  • 11. Benevolent Dictator For Life Ryan Dahl
  • 12. Concurrency Model
  • 13. Non-blocking I/O var fs = require('fs'); fs.readFile('test.txt', function(err, data) { if (err) throw err; console.log('Read file: ', data); }); console.log('Reading file ...');
  • 14. Single Threaded var a = []; function f() { a.push(1); a.push(2); } setTimeout(f, 10); setTimeout(f, 10);
  • 15. API Overview
  • 16. CommonJS Modules $ cat hello.js exports.world = function() { return 'Hello World'; }; $ cat main.js var hello = require('./hello'); console.log(hello.world()); $ node main.js Hello World
  • 17. Child processes $ cat child.js var cmd = 'echo hello; sleep 1; echo world;', spawn = require('child_process').spawn, child = spawn('sh', ['-c', cmd]); child.stdout.on('data', function(chunk) { console.log(chunk.toString()); }); $ node child.js "hellon" # 1 sec delay "worldnn"
  • 18. Http Server $ cat http.js var http = require('http'); http.createServer(function(req, res) { setTimeout(function() { res.writeHead(200); res.end('Thanks for waiting!'); }, 1000); }).listen(4000); $ curl localhost:4000 # 1 sec delay Thanks for waiting!
  • 19. Tcp Server $ cat tcp.js var tcp = require('tcp'); tcp.createServer(function(socket) { socket.on('connect', function() { socket.write("Hi, How Are You?n> "); }); socket.on('data', function(data) { socket.write(data); }); }).listen(4000); $ nc localhost 4000 Hi, How Are You? > Great! Great!
  • 20. DNS $ cat dns.js var dns = require('dns'); dns.resolve('nodejs.org', function(err, addresses) { console.log(addresses); }); $ node dns.js [ '8.12.44.238' ]
  • 21. Watch File $ cat watch.js var fs = require('fs'); fs.watchFile(__filename, function() { console.log('You changed me!'); process.exit(0); }); $ node watch.js # edit watch.js You changed me!
  • 22. And much more • UDP • Buffer • Crypto • Script • Assert • EcmaScript5 ...
  • 23. Suitable Applications • Web frameworks • Real time • Crawlers
  • 24. More Applications • Process monitoring • File uploading • Streaming
  • 25. Interesting projects
  • 26. Package management
  • 27. Web Frameworks • Express.js (Sinatra clone) • Fab.js (Mind-bending & awesome)
  • 28. DOM • jsdom • node-htmlparser • apricot
  • 29. WebSockets Socket.IO
  • 30. Protocol parsers • node-formidable • node-mysql
  • 31. ....
  • 32. Limitations • Weak SSL support • Weak Windows support • 1GB Heap limit on x64 (V8)
  • 33. Hosting
  • 34. Questions? ✎ @felixge / felix@debuggable.com
  • 35. Questions? ✎ @felixge / felix@debuggable.com

×