Narwhal and the Adventures of CommonJS

2,204 views
2,145 views

Published on

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

No Downloads
Views
Total views
2,204
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Narwhal and the Adventures of CommonJS

  1. 1. Narwhal and the Adventures of CommonJS Clinton R. Nixon
  2. 2. CommonJSpromises  to  be  a  standard  environment  that   will  let  JavaScript  code  use  the  same  APIs   with  different  interpreters
  3. 3. Why?JavaScript  is  simple  and  widely-­‐known.To  succeed,  server-­‐side  JavaScript  must  avoid  the  fate  of  Lisp.
  4. 4. CommonJS standardsModulesPackagesSystemBinaryFilesystemUnit  Testing
  5. 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. 6. Narwhalone  of  the  most  mature  CommonJS  implementations
  7. 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. 8. Why?You  can  use  it  todayRhino  makes  it  easy  to  build  off  Java  librariesLots  of  activity,  and  other  implementations  are  working  to  be  compatible  with  itBut  still  needs  lots  of  work
  9. 9. Narwhal packages package.jsonBased  on  the  CommonJS   local.json bin/package  standard lib/tusk  is  a  package  manager    foo.js src/sea  is  an  environment  manager jars/ packages/Every  project  is  a  package engines/ tests/    foo.tests.js
  10. 10. package.json{        "name":  "jake",        "author":  "Francisco  Tolmasky  <francisco@280north.com>",        "contributors":  [                "Tom  Robinson  (http://tlrobinson.net/)  <tom@280north.com>"        ],        "description":  "A  build  system  for  CommonJS,  lifted  from  Rake",        "keywords":  [                "build",                "jake",                "rake",                "make"        ],        "version":  "0.2.1"}
  11. 11. ModulesEach  JS  file  under  lib/  is  a  moduleModules  are  executed  within  a  functionArguments  are  require,  exports,  and  moduleModules  return  exportsCore  concept  of  CommonJS
  12. 12. Module & package demonstration
  13. 13. Testing demonstration
  14. 14. Package management
  15. 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. 16. Important packagesjackjakejsdocsejsnitrobogart
  17. 17. Real apps I wrote
  18. 18. Questions and discussionhttp://narwhaljs.org/Email  me  at  Clinton  R.  Nixon  <crnixon@gmail.com>http://pinboard.in/u:crnixon/t:talk:narwhal/

×