novajs
TRANSCRIPT
![Page 1: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/1.jpg)
Nova
@WeAreFractal@NodeAZ
![Page 2: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/2.jpg)
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.
![Page 3: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/3.jpg)
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)
![Page 4: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/4.jpg)
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
![Page 5: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/5.jpg)
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%
![Page 6: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/6.jpg)
require('events');
● EventEmitter operates the same as it's NodeJS counterpart● Sugar and new functionality (wildcards, namespacing, etc.) to be added
● Progress: 100%
![Page 7: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/7.jpg)
require('assert');
● AssertionError thrown on failure● Operates the same as it's NodeJS counterpart● Used to test itself – Microsoft approved
● Progress: 100%
![Page 8: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/8.jpg)
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)
![Page 9: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/9.jpg)
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
![Page 10: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/10.jpg)
Cool story bro
● Microlib compilers are nothing new (Ender)● require() in the browser is nothing new (brequire, requirejs)
![Page 11: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/11.jpg)
NOPE
● RequireJS is super-optimized but modules are nothing like NodeJS modules● Ender simply doesn't have enough libraries to do what we want● NodeJS in 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();});
![Page 12: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/12.jpg)
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
![Page 13: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/13.jpg)
Size
● Nova Core (All NodeJS libs) 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.
![Page 14: Novajs](https://reader033.vdocument.in/reader033/viewer/2022060116/5583d255d8b42ace2f8b4a57/html5/thumbnails/14.jpg)
return;
@WeAreFractalCode: http://github.com/wearefractal/novaDocs: http://wearefractal.github.com/nova
0.0.3 will be released tonight (hopefully)