Novajs

627 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
627
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Novajs

  1. 1. Nova<br />@WeAreFractal<br />@NodeAZ<br />
  2. 2. Inspiration<br /> Lots of great NodeJS libraries we want to use on the client<br /> Writing NodeJS code > writing browser code<br /> Seemed like fun<br /> Kind sir at the Adobe group said it couldn't be done.<br />
  3. 3. Goals<br /> Map as much NodeJS functionality to the browser as we possibly can<br /> Keep the syntax/usage the same<br /> Keep it tiny, keep it simple<br /> Don't use any external dependencies – too lame, we keep it sikk<br /> Hot interface for building your packages<br /> Needs to be extremely easy to extend and use with existing libraries<br /> ABSOLUTELY MUST be compatible with UselessJS (50% done)<br />
  4. 4. Limitations<br /> Initiating P2P outbound connections – IMPOSSIBLE (kind of)<br /> System interactions can only be emulated at best<br /> HTML5 localStorage limits – 5MB or less<br /> JS vs. Native speed – not too slick<br />
  5. 5. require('fs');<br /> File reads – Attempts HTML5 localStorage, defaults to AJAX<br /> File writes – HTML5 localStorage<br /> Mock file system is set up within HTML5 localStorage to emulate folder and file properties<br /> File watching and events done using localStorage events<br /> Syntax identical to NodeJS<br /> Progress: 50%<br />
  6. 6. require('events');<br />EventEmitteroperates the same as it's NodeJS counterpart<br /> Sugar and new functionality (wildcards, namespacing, etc.) to be added<br /> Progress: 100%<br />
  7. 7. require('assert');<br />AssertionErrorthrown on failure<br /> Operates the same as it's NodeJS counterpart<br /> Used to test itself – Microsoft approved<br /> Progress: 100%<br />
  8. 8. TODO<br /> require('sys') – 100%<br /> require('util') – 99%<br /> require('readline') – 50%<br /> require('http') – 25% (Rewriting native parsers in JS = fail)<br /> require('os') – 75% (Needs more efficient detection methods)<br />
  9. 9. require('3rd-party');<br /> require('es5-shim') - magically make everything work on older browsers<br /> require('jquery') - 229kb of fun<br /> require('zepto') - jQuery with the fat sucked out<br /> Adding existing libraries to nova is extremely simple<br />
  10. 10. Cool story bro<br />Microlibcompilers are nothing new (Ender)<br /> require() in the browser is nothing new (brequire, requirejs)<br />
  11. 11. NOPE<br />RequireJSis super-optimized but modules are nothing like NodeJS modules<br /> Ender simply doesn't have enough libraries to do what we want<br />NodeJSin the browser hasn't been done before (hopefully)<br />require.config({<br />baseUrl: require.isBrowser ? "./" : "./exports/"<br />});<br />require(["require", "vanilla", "funcSet", "assign", "assign2"],<br /> function (require, vanilla, funcSet, assign, assign2) {<br />doh.register("exports", [<br /> function exports(t) {<br /> //Use the imports<br /> }]);<br />doh.run();<br />});<br />
  12. 12. NATIVE CODE – HOPE!<br /> Chromium Native Client allows you to access native code in the browser<br /> Native client gives us unlimited storage and a sandboxed file system<br /> Wrapping native libraries like zlib and more can be simplified<br /> May allow us to run standard NodeJS libraries without modification<br />
  13. 13. Size<br /> Nova Core (All NodeJSlibs) is currently 4.3k minified, 1.1k gzipped<br /> Adding DOM manipulation and networking modules only bumps it to 5.4k/1.7k<br /> You can pick and choose modules – your size may vary.<br />
  14. 14. return;<br />@WeAreFractal<br />Code: http://github.com/wearefractal/nova<br />Docs: http://wearefractal.github.com/nova<br />0.0.3 will be released tonight (hopefully)<br />

×