• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Common Node
 

Common Node

on

  • 2,343 views

 

Statistics

Views

Total Views
2,343
Views on SlideShare
2,328
Embed Views
15

Actions

Likes
0
Downloads
6
Comments
0

2 Embeds 15

http://lanyrd.com 8
http://www.linkedin.com 7

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Common Node Common Node Presentation Transcript

    • Intro to Common Node #camdug 27.08.2011
    • Why use JavaScript on the server?
      • Language of the browser, widely accessible
      • Dynamic language
      • Closures and asynchronous programming
      • Diverse, active, growing community
      • We are stuck with it for the foreseeable future
    •  
    • Akshell NarwhalJS Wakanda RingoJS
    • 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 ???
    • 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;], }
    • Node.js Event Loop
      • Handle all I/O in one process
      • No blocking calls, use callbacks instead
      • Less memory used and higher throughput due to fewer context switches
      • Use JavaScript closures to capture state
    • 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); } } }
    • Async vs. Sync http.get(url1) + http.get(url2)
    • Interoperability
      • Pure JavaScript CommonJS modules can run in any environment
        • Templating, parsing, formatting, encoding
      • Anything that does I/O must expose either a synchronous or an asynchronous API
        • Dictates the style of interface exposed by higher level packages
    • Common Node
      • Implements a number of synchronous CommonJS specifications on top of Node
        • Binary, IO, Filesystem, JSGI and more
      • Uses node-fibers
        • Co routine implementation, not a fork or a hack of Node
      • Google's Traceur to support latest language features
      • Bridges the gap between platforms, sync and async
      • Google “ common node ”, watch on GitHub
    •  
      • Thank you!
      • Comments?
      • @olegpodsechin