Narwhal and the Adventures of CommonJS

20
Narwhal and the Adventures of CommonJS Clinton R. Nixon

Transcript of Narwhal and the Adventures of CommonJS

  • 1.Narwhal and the Adventures of CommonJSClinton R. Nixon

2. CommonJSpromises to be a standard environment that will let JavaScript code use the same APIs with dierent interpreters 3. Why?JavaScript is simple and widely-known.To succeed, server-side JavaScript must avoid the fate of Lisp. 4. CommonJS standardsModulesPackagesSystemBinaryFilesystemUnit Testing 5. CommonJS implementationsNarwhal (Rhino, v8, JSC)Flusspferd (Spidermonkey/C++)node.js (v8; not many standards or proposals implemented)v8cgi (v8)GPSEE (Spidermonkey/C)RingoJS (Rhino; was Helma NG)Perservere (Rhino)SproutCore (in-browser) 6. Narwhalone of the most mature CommonJS implementations 7. NarwhalA CommonJS platform or implementationArguably the most mature implementationRuns on several interpretersRhino has the most complete implementationJavaScriptCore works well on MacsEasy to add new engines if youre a language implementation hacker 8. Why?You can use it todayRhino makes it easy to build o Java librariesLots of activity, and other implementations are working to be compatible with itBut still needs lots of work 9. Narwhal packagespackage.jsonBased on the CommonJS local.jsonbin/package standardlib/tusk is a package manager foo.jssrc/sea is an environment manager jars/packages/Every project is a packageengines/tests/ foo.tests.js 10. package.json{ "name": "jake", "author": "Francisco Tolmasky ", "contributors": [ "Tom Robinson (http://tlrobinson.net/) " ], "description": "A build system for CommonJS, lifted from Rake", "keywords": [ "build", "jake", "rake", "make" ], "version": "0.2.1"} 11. ModulesEach JS le under lib/ is a moduleModules are executed within a functionArguments are require, exports, and moduleModules return exportsCore concept of CommonJS 12. Module & package demonstration 13. Testing demonstration 14. Package management 15. sources.json{ "version": 2, "includes": ["http://github.com/280north/narwhal/raw/master/catalog-2.json"], "sources": { "dice": { "type": "github", "user": "crnixon", "name": "narwhal-dice" }, "caffeine": { "type": "github", "user": "crnixon", "name": "narwhal-caffeine" } }} 16. Important packagesjackjakejsdocsejsnitrobogart 17. Real apps I wrote 18. Questions and discussionhttp://narwhaljs.org/Email me at Clinton R. Nixon http://pinboard.in/u:crnixon/t:talk:narwhal/