1 / 11

Interesting facts about node.js

Interesting facts about node.js. What do Web Servers do?. Asynchronous I/O How do they do that? ..threads (usually). All about Threads. They Suck The End. Threads require context s witching. They require evils such as synchronization and create headaches with maintaining concurrency.

damien
Download Presentation

Interesting facts about node.js

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interesting facts about node.js

  2. What do Web Servers do? Asynchronous I/O How do they do that?..threads (usually)

  3. All about Threads They Suck The End

  4. Threads require context switching They require evils such as synchronization and create headaches with maintaining concurrency

  5. node.js has an Event Queue

  6. Why use JavaScript? Web developers are already a little familiar with it( just a tad ) JavaScript has never needed more than one thread because it’s entirely event-driven JavaScript never had any type of blocking I/O because it has no built-in I/O API’s

  7. Blocking I/O Syncronous function call in C#public static void getConfig() { StreamReadersr = new StreamReader("cfg.txt"); using (("TestFile.txt")) { String line = sr.ReadToEnd();Console.WriteLine(line); }}:function will wait for results..

  8. Asynchronous I/O Asyncronous function call in node.jsfunction getConfig(req, res) {fs.readFile ("c:\\config.xml", function(err, data) { if (!err) res.send(200, JSON.stringify(data)); }); } : execution falls through and continues..

  9. What about Error handling? If function is synchronous, simply return an error If function is asynchronous, then first arg returned is err If flow is more complex, then add an event listener and emit an error event from anywhere within your code as opposed to using try / catch / throw which really only work on synchronous code.

  10. node.js uses Google’s V8 Compiles JavaScript to machine language, as opposed to bytecode, for speed Uses advanced optimization techniques, such as copy elision to avoid duplication of objects Made from Scratch, its Open Source, andits used in used in MongoDB and Chrome

  11. Why look into node.js Very active Open Source community (ahh-ma-zing). socket.io express uglify-js less-cssasync jade mongo Designed for building fast and scalable real-time mobile applications and websites. Its coming to Desktop too! Dynamic language that is consistently asynchronous and compatible with browser code libraries.

More Related