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