Intro to Common Node #camdug 27.08.2011
Why use JavaScript on the server? <ul><li>Language of the browser, widely accessible </li></ul><ul><li>Dynamic language </...
 
Akshell NarwhalJS Wakanda RingoJS
CommonJS modules // math.js exports.add = function(a, b) {  return a + b; } // server.js var add = require('math').add; co...
CommonJS packages // package.json { &quot;name&quot;: &quot;hello&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;des...
Node.js Event Loop <ul><li>Handle all I/O in one process </li></ul><ul><li>No blocking calls, use callbacks instead </li><...
Async  vs.   Sync  function add(callback) { http.get(url1, function(response1) { var part1 = response1.data; http.get(url2...
Async   vs.  Sync http.get(url1) + http.get(url2)
Interoperability <ul><li>Pure JavaScript CommonJS modules can run in any environment </li></ul><ul><ul><li>Templating, par...
Common Node <ul><li>Implements a number of  synchronous  CommonJS specifications on top of Node </li></ul><ul><ul><li>Bina...
 
<ul><li>Thank you! </li></ul><ul><li>Comments? </li></ul><ul><li>@olegpodsechin </li></ul>
Upcoming SlideShare
Loading in …5
×

Common Node

3,606
-1

Published on

Published in: Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,606
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Common Node

  1. 1. Intro to Common Node #camdug 27.08.2011
  2. 2. Why use JavaScript on the server? <ul><li>Language of the browser, widely accessible </li></ul><ul><li>Dynamic language </li></ul><ul><li>Closures and asynchronous programming </li></ul><ul><li>Diverse, active, growing community </li></ul><ul><li>We are stuck with it for the foreseeable future </li></ul>
  3. 4. Akshell NarwhalJS Wakanda RingoJS
  4. 5. CommonJS modules // math.js exports.add = function(a, b) { return a + b; } // server.js var add = require('math').add; console.log(add(2, 2)); // client.js ???
  5. 6. CommonJS packages // package.json { &quot;name&quot;: &quot;hello&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;description&quot;: &quot;Hello world package&quot;, &quot;keywords&quot;: [&quot;hello&quot;, &quot;world&quot;], &quot;author&quot;: &quot;John Smith <john@smith.com>&quot;, &quot;main&quot;: &quot;./lib/hello.js&quot;, &quot;dependencies&quot;: {&quot;whatever&quot; : &quot;1&quot;}, &quot;engines&quot; : [&quot;v8&quot;, &quot;node&quot;, &quot;rhino&quot;], }
  6. 7. Node.js Event Loop <ul><li>Handle all I/O in one process </li></ul><ul><li>No blocking calls, use callbacks instead </li></ul><ul><li>Less memory used and higher throughput due to fewer context switches </li></ul><ul><li>Use JavaScript closures to capture state </li></ul>
  7. 8. Async vs. Sync function add(callback) { http.get(url1, function(response1) { var part1 = response1.data; http.get(url2, function(response2) { var part2 = response2.data; callback(part1 + part2); } } }
  8. 9. Async vs. Sync http.get(url1) + http.get(url2)
  9. 10. Interoperability <ul><li>Pure JavaScript CommonJS modules can run in any environment </li></ul><ul><ul><li>Templating, parsing, formatting, encoding </li></ul></ul><ul><li>Anything that does I/O must expose either a synchronous or an asynchronous API </li></ul><ul><ul><li>Dictates the style of interface exposed by higher level packages </li></ul></ul>
  10. 11. Common Node <ul><li>Implements a number of synchronous CommonJS specifications on top of Node </li></ul><ul><ul><li>Binary, IO, Filesystem, JSGI and more </li></ul></ul><ul><li>Uses node-fibers </li></ul><ul><ul><li>Co routine implementation, not a fork or a hack of Node </li></ul></ul><ul><li>Google's Traceur to support latest language features </li></ul><ul><li>Bridges the gap between platforms, sync and async </li></ul><ul><li>Google “ common node ”, watch on GitHub </li></ul>
  11. 13. <ul><li>Thank you! </li></ul><ul><li>Comments? </li></ul><ul><li>@olegpodsechin </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×