SlideShare a Scribd company logo
The Future of Server Side JavaScript
/me #startups #akshell #ringojs #moscowjs #dailyjs
 
Node.js Ideal use cases Real time apps, infrastructure duct tape Badly suited for CRUD, command line tools, CPU heavy loads Easy to get started with Difficult to get into production
 
 
Akshell NarwhalJS RingoJS Wakanda GPSEE v8cgi
ServerJS Fragmentation
Sync vs. Async
 
“ async style is kicking sync style's back end”
 
sync is “on top of” async –  a higher level of abstraction
Sync   vs.  Async   function add(callback) { http.get(url1, function(response1) { var part1 = response1.data; http.get(url2, function(response2) { var part2 = response2.data; callback(part1 + part2); } } }
Sync  vs.   Async http.get(url1).data + http.get(url2).data
Interoperability Pure JavaScript modules run anywhere Templating, parsing, formatting, encoding Anything doing I/O exposes sync or async API Defines the interface exposed by higher level packages
 
 
CommonJS /1 Modules/1.1 Packages/1.0 Assert Console System/1.0
CommonJS /2 Binary/B IO/A JSGI 0.3 Filesystem/A
CommonJS /3 HTTP Client /A Sockets/A Subprocess
common-node Implements  synchronous  CommonJS proposals using  node-fibers   Traceur  to support latest language features Bridges the gap between platforms, sync and async
What it's good for?
everything!
What's it  actually  good for? Business logic Lots of state, fine grained error handling CRUD Java, Rails, PHP, Python Command line tools Cross platform portability
On Threads & Fibers “ Threads suck”  - Brendan Eich, creator of JavaScript “ Fibers introduce interleaving hazards — Any function call can cause a yield and then your closure invariants *may be* broken.” - Kris Kowal, creator of CommonJS/Modules
Concurrency in JavaScript “ You shouldn’t think that event-based concurrency eliminates synchronization, or shared memory, or anything other than preemption” - Sam Tobin-Hochstadt, member of the Ecma TC39 committee on JavaScript
fibers /1 Co routine implementation using libcoro  Co-operative multitasking Implicit synchronization
fibers /2 Not a fork or a hack of Node No wrapper script required V8 Context and 64KB stack per fiber Will run on Windows
Node.js process [ closure closure t  ->
RingoJS (0.8) process thread  stack process thread  stack t  ->
Common Node (fibers) process fiber stack fiber stack [ t  ->
Node.js Common Node RingoJS Process Count Single Single Multiple State Closure Fiber Stack Thread Stack Multitasking User (co-op) Library (co-op) OS (pre-empt) Memory Usage Low Low High “ Jitter” High High Low
Internals - sleep exports.sleep = function(milliseconds) { var fiber = Fiber.current; setTimeout(function() { fiber.run(); }, milliseconds); yield(); } ;
Internals – HttpClient /1 var req = http.request(options, function(r) { fiber.run(r); }); req.on('error', function(error) { fiber.run(error); }); this.guts.body.forEach(function(block) { req.write(block.buffer || block); }); req.end();
Internals – HttpClient /2 var result = yield(); if(result instanceof Error) throw new Error(result.message); return { status: result.statusCode, headers: result.headers, body: new Stream(result) };
Internals - IO // on 'data', 'end', 'error' // pause when draining var listeners = attach(this.stream); var data = yield(); detach(this.stream, listeners);
Examples
JSGI exports.app = function(request) { return { status: 200, headers: {}, body: ['Hello World!']  // openRaw(module.filename) }; };
Spawn & Sleep exports.app = function(request) { spawn(function() { sleep(10000); console.log('Hello Server!'); }); return { status: 200, headers: {}, body: ['Hello Client!'] }; };
HTTP Proxy var HttpClient = require('httpclient').HttpClient; exports.app = function(req) { req.url = 'http://nodejs.org'; return new HttpClient(req).finish(); };
Twitter Streaming /1 var stream = new TextStream(   new HttpClient({ method:  'POST', url:  '...', headers: {} body: ['track='+system.args[4]], timeout: 10000 }).finish().body);
Twitter Streaming /2 var line; while(true) { line = stream.readLine(); if(!line.length) break; if(line.length > 1) { var message = JSON.parse(line); console.log(message.text); } }
Benchmarks ab -n 50000 -c 50
hello-world exports.app = function() { return { status: 200, headers: { 'Content-Type': 'text/plain' }, body: ['Hello World!\n'] }; };
 
string-alloc exports.app = function(request) { for( var i = 1; i <= 50; i++) b.decodeToString(&quot;ascii&quot;); return { status: 200, headers: {}, body: [b] }; };
 
parse-json exports.app = function(request) { JSON.parse(json); return { status: 200, headers: {}, body: [json] }; };
 
static-file exports.app = function() { return {  status: 200,  headers: {},  body:  openRaw('../README.md') }; };
 
set-timeout exports.app = function() { sleep(100); return { status: 200, headers: {}, body: [] }; };
 
Throughput
Contributing Google  “ common node ” github.com/olegp/common-node/ npm -g install common-node
SyncJS Fragmentation
Toolkits vs. Frameworks
 
 
 
 
 
Next Steps Stick backport Database access selectjs.com Higher level packages (wiki)
common-utils base64: encode, decode hash: sha1 etc. url: parse, format, resolve string: format, trim etc. date: format, add, before, after etc. array: contains etc. object: clone, merge etc.
One more thing ... Third party services & APIs olegp/rest-wrapper thelockerproject.org Browser based IDEs (Cloud9, Akshell) Social hosting PINF, automatic redeployment, continuous integration etc.
Summary sync and async will co-exist toolkits instead of frameworks implementation driven de-facto standards we are just getting started!
Thank you! @olegpodsechin

More Related Content

PPT
Server side JavaScript: going all the way
KEY
Node.js - Best practices
PDF
Node.js - A Quick Tour
PPT
Node js presentation
PDF
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
PDF
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
KEY
Streams are Awesome - (Node.js) TimesOpen Sep 2012
PDF
Nodejs Explained with Examples
Server side JavaScript: going all the way
Node.js - Best practices
Node.js - A Quick Tour
Node js presentation
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Nodejs Explained with Examples

What's hot (20)

PDF
Callbacks and control flow in Node js
PDF
Nick Sieger JRuby Concurrency EMRubyConf 2011
KEY
Introduction to node.js
PDF
PDF
Node.js Event Loop & EventEmitter
PDF
Comet with node.js and V8
PPT
Building your first Node app with Connect & Express
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
KEY
A million connections and beyond - Node.js at scale
PPT
JavaScript Event Loop
PPTX
Avoiding Callback Hell with Async.js
PPTX
How NOT to write in Node.js
PPTX
introduction to node.js
PPTX
Beyond Profilers: Tracing Node.js Transactions
PDF
ECMAScript 6
PPTX
Node.js System: The Approach
PPTX
PDF
Non-blocking I/O, Event loops and node.js
PDF
Nodejs - A quick tour (v6)
PPTX
JavaScript Engines and Event Loop
Callbacks and control flow in Node js
Nick Sieger JRuby Concurrency EMRubyConf 2011
Introduction to node.js
Node.js Event Loop & EventEmitter
Comet with node.js and V8
Building your first Node app with Connect & Express
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
A million connections and beyond - Node.js at scale
JavaScript Event Loop
Avoiding Callback Hell with Async.js
How NOT to write in Node.js
introduction to node.js
Beyond Profilers: Tracing Node.js Transactions
ECMAScript 6
Node.js System: The Approach
Non-blocking I/O, Event loops and node.js
Nodejs - A quick tour (v6)
JavaScript Engines and Event Loop
Ad

Viewers also liked (7)

PPS
Trikala
PPT
Common Node
PPTX
Árboles para dibujar
PPT
Oppsummering av blogging i samarbeidet med Joachim
PDF
Oppsummering Av Blogging Joe
PPT
What every developer can learn from startups
PPT
Current State of Server Side JavaScript
Trikala
Common Node
Árboles para dibujar
Oppsummering av blogging i samarbeidet med Joachim
Oppsummering Av Blogging Joe
What every developer can learn from startups
Current State of Server Side JavaScript
Ad

Similar to JS everywhere 2011 (20)

PDF
Nodejs - A quick tour (v5)
KEY
node.js: Javascript's in your backend
PPT
The future of server side JavaScript
PDF
Nodejs - A quick tour (v4)
PDF
Introduction to Node.js
KEY
NodeJS
PDF
Nodejs - Should Ruby Developers Care?
KEY
node.js dao
KEY
Playing With Fire - An Introduction to Node.js
PDF
Intro to node.js - Ran Mizrahi (27/8/2014)
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
KEY
Node.js - A practical introduction (v2)
PDF
Matthew Eernisse, NodeJs, .toster {webdev}
PPTX
A slightly advanced introduction to node.js
PPTX
Building and Scaling Node.js Applications
PPTX
Node.js: A Guided Tour
PPTX
Introduction to Node.js
PDF
Developing realtime apps with Drupal and NodeJS
PDF
Event driven programming -- Node.JS
PDF
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
Nodejs - A quick tour (v5)
node.js: Javascript's in your backend
The future of server side JavaScript
Nodejs - A quick tour (v4)
Introduction to Node.js
NodeJS
Nodejs - Should Ruby Developers Care?
node.js dao
Playing With Fire - An Introduction to Node.js
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (28/8/14)
Node.js - A practical introduction (v2)
Matthew Eernisse, NodeJs, .toster {webdev}
A slightly advanced introduction to node.js
Building and Scaling Node.js Applications
Node.js: A Guided Tour
Introduction to Node.js
Developing realtime apps with Drupal and NodeJS
Event driven programming -- Node.JS
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...

More from Oleg Podsechin (9)

PDF
Why SaaS (in Helsinki)?
PDF
Staying safe in the cloud
PDF
Tips from angular js users anonymous
PPT
AngularJS - the folly of choice
PDF
Lean and mean MongoDB
PPT
PPT
On Platforms
PPT
PPT
Grid and Cloud Computing Intro
Why SaaS (in Helsinki)?
Staying safe in the cloud
Tips from angular js users anonymous
AngularJS - the folly of choice
Lean and mean MongoDB
On Platforms
Grid and Cloud Computing Intro

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
20250228 LYD VKU AI Blended-Learning.pptx
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

JS everywhere 2011

  • 1. The Future of Server Side JavaScript
  • 2. /me #startups #akshell #ringojs #moscowjs #dailyjs
  • 3.  
  • 4. Node.js Ideal use cases Real time apps, infrastructure duct tape Badly suited for CRUD, command line tools, CPU heavy loads Easy to get started with Difficult to get into production
  • 5.  
  • 6.  
  • 7. Akshell NarwhalJS RingoJS Wakanda GPSEE v8cgi
  • 10.  
  • 11. “ async style is kicking sync style's back end”
  • 12.  
  • 13. sync is “on top of” async – a higher level of abstraction
  • 14. Sync vs. Async function add(callback) { http.get(url1, function(response1) { var part1 = response1.data; http.get(url2, function(response2) { var part2 = response2.data; callback(part1 + part2); } } }
  • 15. Sync vs. Async http.get(url1).data + http.get(url2).data
  • 16. Interoperability Pure JavaScript modules run anywhere Templating, parsing, formatting, encoding Anything doing I/O exposes sync or async API Defines the interface exposed by higher level packages
  • 17.  
  • 18.  
  • 19. CommonJS /1 Modules/1.1 Packages/1.0 Assert Console System/1.0
  • 20. CommonJS /2 Binary/B IO/A JSGI 0.3 Filesystem/A
  • 21. CommonJS /3 HTTP Client /A Sockets/A Subprocess
  • 22. common-node Implements synchronous CommonJS proposals using node-fibers Traceur to support latest language features Bridges the gap between platforms, sync and async
  • 25. What's it actually good for? Business logic Lots of state, fine grained error handling CRUD Java, Rails, PHP, Python Command line tools Cross platform portability
  • 26. On Threads & Fibers “ Threads suck” - Brendan Eich, creator of JavaScript “ Fibers introduce interleaving hazards — Any function call can cause a yield and then your closure invariants *may be* broken.” - Kris Kowal, creator of CommonJS/Modules
  • 27. Concurrency in JavaScript “ You shouldn’t think that event-based concurrency eliminates synchronization, or shared memory, or anything other than preemption” - Sam Tobin-Hochstadt, member of the Ecma TC39 committee on JavaScript
  • 28. fibers /1 Co routine implementation using libcoro Co-operative multitasking Implicit synchronization
  • 29. fibers /2 Not a fork or a hack of Node No wrapper script required V8 Context and 64KB stack per fiber Will run on Windows
  • 30. Node.js process [ closure closure t ->
  • 31. RingoJS (0.8) process thread stack process thread stack t ->
  • 32. Common Node (fibers) process fiber stack fiber stack [ t ->
  • 33. Node.js Common Node RingoJS Process Count Single Single Multiple State Closure Fiber Stack Thread Stack Multitasking User (co-op) Library (co-op) OS (pre-empt) Memory Usage Low Low High “ Jitter” High High Low
  • 34. Internals - sleep exports.sleep = function(milliseconds) { var fiber = Fiber.current; setTimeout(function() { fiber.run(); }, milliseconds); yield(); } ;
  • 35. Internals – HttpClient /1 var req = http.request(options, function(r) { fiber.run(r); }); req.on('error', function(error) { fiber.run(error); }); this.guts.body.forEach(function(block) { req.write(block.buffer || block); }); req.end();
  • 36. Internals – HttpClient /2 var result = yield(); if(result instanceof Error) throw new Error(result.message); return { status: result.statusCode, headers: result.headers, body: new Stream(result) };
  • 37. Internals - IO // on 'data', 'end', 'error' // pause when draining var listeners = attach(this.stream); var data = yield(); detach(this.stream, listeners);
  • 39. JSGI exports.app = function(request) { return { status: 200, headers: {}, body: ['Hello World!'] // openRaw(module.filename) }; };
  • 40. Spawn & Sleep exports.app = function(request) { spawn(function() { sleep(10000); console.log('Hello Server!'); }); return { status: 200, headers: {}, body: ['Hello Client!'] }; };
  • 41. HTTP Proxy var HttpClient = require('httpclient').HttpClient; exports.app = function(req) { req.url = 'http://nodejs.org'; return new HttpClient(req).finish(); };
  • 42. Twitter Streaming /1 var stream = new TextStream( new HttpClient({ method: 'POST', url: '...', headers: {} body: ['track='+system.args[4]], timeout: 10000 }).finish().body);
  • 43. Twitter Streaming /2 var line; while(true) { line = stream.readLine(); if(!line.length) break; if(line.length > 1) { var message = JSON.parse(line); console.log(message.text); } }
  • 44. Benchmarks ab -n 50000 -c 50
  • 45. hello-world exports.app = function() { return { status: 200, headers: { 'Content-Type': 'text/plain' }, body: ['Hello World!\n'] }; };
  • 46.  
  • 47. string-alloc exports.app = function(request) { for( var i = 1; i <= 50; i++) b.decodeToString(&quot;ascii&quot;); return { status: 200, headers: {}, body: [b] }; };
  • 48.  
  • 49. parse-json exports.app = function(request) { JSON.parse(json); return { status: 200, headers: {}, body: [json] }; };
  • 50.  
  • 51. static-file exports.app = function() { return { status: 200, headers: {}, body: openRaw('../README.md') }; };
  • 52.  
  • 53. set-timeout exports.app = function() { sleep(100); return { status: 200, headers: {}, body: [] }; };
  • 54.  
  • 56. Contributing Google “ common node ” github.com/olegp/common-node/ npm -g install common-node
  • 59.  
  • 60.  
  • 61.  
  • 62.  
  • 63.  
  • 64. Next Steps Stick backport Database access selectjs.com Higher level packages (wiki)
  • 65. common-utils base64: encode, decode hash: sha1 etc. url: parse, format, resolve string: format, trim etc. date: format, add, before, after etc. array: contains etc. object: clone, merge etc.
  • 66. One more thing ... Third party services & APIs olegp/rest-wrapper thelockerproject.org Browser based IDEs (Cloud9, Akshell) Social hosting PINF, automatic redeployment, continuous integration etc.
  • 67. Summary sync and async will co-exist toolkits instead of frameworks implementation driven de-facto standards we are just getting started!