Your SlideShare is downloading. ×
CommonJS: JavaScript Everywhere
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

CommonJS: JavaScript Everywhere

5,435
views

Published on

JavaScript is an enormously popular programming language, because of its unique place as the programming language of the web. Outside of that domain, JS is barely a blip compared to other dynamic …

JavaScript is an enormously popular programming language, because of its unique place as the programming language of the web. Outside of that domain, JS is barely a blip compared to other dynamic languages like Python and Ruby. Outside of the browser, JavaScript is lacking something critical: a significant standard library. Thanks to a powerful standard library and a common module system, sophisticated applications can be written in Python and run unchanged on Windows, Mac and Linux and even across different interpreters including Jython and IronPython. The CommonJS project (formerly ServerJS) is building up a standard library API to give privileged JavaScript applications this same kind of interop. Imagine a server-side webapp that runs equally well in Rhino, SpiderMonkey and v8. We're getting there. Even better, those apps can easily share modules between the browser and the server, which is something you don't get in other languages. In this talk, I'll provide quick background on the project and demos of several implementations of the emerging standard, including how CommonJS impacts Mozilla's Jetpack and Bespin projects.


0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,435
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
84
Comments
0
Likes
11
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. CommonJS JavaScript Everywhere Kevin Dangoor, Kris Kowal, Tom Robinson jsconf.eu — 2009-11-07
  • 2. Kevin Dangoor Mozilla Labs
  • 3. Kris Kowal FastSoft, Inc.
  • 4. problem + CommonJS = solution
  • 5. There are many ways to do these things in JavaScript. There is no standard way to do these things in JavaScript.
  • 6. import json import hashlib var file = require("file"); import sys var system = require("system"); var md5 = require("md5"); def main(args): raw_data = open(args[1]).read() exports.main = function(args) { strings = json.loads(raw_data) var rawData = file.read(args[1]); h = hashlib.md5() var strings = JSON.parse(rawData); var hashed = md5.hash(strings.join("")); for s in strings: print(hashed.toString(16)); h.update(s) }; print h.hexdigest() if (module.id == require.main) { exports.main(system.args); if __name__ == "__main__": } main(sys.argv)
  • 7. bash-3.2$ python simple.py testdata.json 900150983cd24fb0d6963f7d28e17f72 bash-3.2$ js simple.js testdata.json 900150983cd24fb0d6963f7d28e17f72 http://www.codinghorror.com/blog/archives/000818.html
  • 8. CommonJS You can make a difference! http://commonjs.org/
  • 9. Q&A http://commonjs.org/