The future of server side JavaScript

4,905 views

Published on

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

No Downloads
Views
Total views
4,905
On SlideShare
0
From Embeds
0
Number of Embeds
32
Actions
Shares
0
Downloads
47
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

The future of server side JavaScript

  1. 1. The future of server side JavaScript @olegpodsechin #froscon 20.08.2011
  2. 2. Why use JavaScript on the server? <ul><li>Language of the browser </li></ul><ul><ul><li>Competition amongst browser vendors means increased performance </li></ul></ul><ul><ul><li>Code reuse between the server and client, no need for context switching </li></ul></ul><ul><li>Dynamic language </li></ul><ul><ul><li>No unnecessary constraints, allows one to mix procedural, object oriented and functional styles </li></ul></ul><ul><ul><li>Allows for meta programing </li></ul></ul><ul><ul><li>Data in JSON, no marshalling reduces amount of code </li></ul></ul>
  3. 3. Why use JavaScript on the server? <ul><li>Lingua franca of the web </li></ul><ul><ul><li>Widely accessible, even to beginning developers </li></ul></ul><ul><ul><li>Widely available in terms of platforms </li></ul></ul><ul><ul><li>Decent IDE support </li></ul></ul><ul><li>Closures work well with asynchronous, real time web </li></ul><ul><li>Diverse, active, growing community – http://communityjs.org </li></ul><ul><li>We are stuck with it for the foreseeable future </li></ul>
  4. 4. It's Trendy
  5. 5. ServerJS != Node <ul><li>Engines </li></ul><ul><li>Environments </li></ul><ul><li>Platforms </li></ul><ul><li>Frameworks </li></ul>
  6. 6. Engines <ul><li>1996 SpiderMonkey (Mozilla) </li></ul><ul><li>1998 Rhino (Mozilla) </li></ul><ul><li>2008 Nitro/SquirrelFish (Apple) </li></ul><ul><li>2008 V8 (Google) </li></ul><ul><li>2011 Chakra (Microsoft) </li></ul><ul><li>2012 Nashorn (Oracle) </li></ul>
  7. 7. Rhino <ul><li>JavaScript 1.7 </li></ul><ul><li>Interpreted or compiled to Java bytecode, allows for continuations </li></ul><ul><li>Includes new and old features like destructuring assignment (var {a, b} = x) and E4X </li></ul><ul><li>Easy access to Java classes </li></ul><ul><li>Recent patches improve performance, e.g. InvokeDynamic in Java7 </li></ul>
  8. 8. V8 <ul><li>EcmaScript 5 </li></ul><ul><li>Compiles to native code – fast! </li></ul><ul><li>Extended via native libraries </li></ul><ul><li>Primarily targets the web browser </li></ul>
  9. 9. CommonJS <ul><li>Modules - 1.0, 1.1 , Async/A </li></ul><ul><li>Packages - 1.0, 1.1 </li></ul><ul><li>Console </li></ul><ul><li>System </li></ul><ul><li>Unit Testing – 1.0 </li></ul><ul><li>Binary - A, B , C, D, E, Lite, F </li></ul><ul><li>IO - A , B, C </li></ul><ul><li>Filesystem - A , B </li></ul><ul><li>JSGI - 0.2, 0.3 </li></ul><ul><li>HttpClient – A , B </li></ul>
  10. 10. CommonJS modules // math.js exports.add = function(a, b) { return a + b; } // server.js var add = require('math').add; console.log(add(2, 2)); // client.js ???
  11. 11. CommonJS packages // package.json { &quot;name&quot;: &quot;hello&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;description&quot;: &quot;Hello world package&quot;, &quot;keywords&quot;: [&quot;hello&quot;, &quot;world&quot;], &quot;author&quot;: &quot;John Smith <john@smith.com>&quot;, &quot;main&quot;: &quot;./lib/hello.js&quot;, &quot;dependencies&quot;: {&quot;whatever&quot; : &quot;1&quot;}, &quot;engines&quot; : [&quot;v8&quot;, &quot;node&quot;, &quot;rhino&quot;], }
  12. 12. Future of CommonJS <ul><li>http://groups.google.com/group/commonjs </li></ul><ul><li>Node mostly ignored CommonJS </li></ul><ul><li>AMD split out into separate mailing list </li></ul><ul><li>UncommonJS https://github.com/kriskowal/uncommonjs </li></ul>
  13. 13. Environments <ul><li>1996 Netscape Livewire </li></ul><ul><li>1998 Helma (Rhino) </li></ul><ul><li>2007 AppJet (Rhino) </li></ul><ul><li>2008 CouchDB / Couch Apps (SpiderMonkey) </li></ul><ul><li>2008 RingoJS (Rhino) </li></ul><ul><li>2009 Narwhal (Rhino, V8, SpiderMonkey) </li></ul><ul><li>2009 Node (V8) </li></ul><ul><li>2010 Akshell (V8) </li></ul><ul><li>2011 Wakanda (Nitro) </li></ul><ul><li>Over 30 in total http://wiki.commonjs.org/wiki/Implementations </li></ul>
  14. 14. Sync vs. Async http.get(url1) + http.get(url2)
  15. 15. 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); } } }
  16. 16. Interoperability <ul><li>Pure JavaScript CommonJS modules can run in any environment </li></ul><ul><ul><li>Templating, parsing, formatting, encoding – what else? </li></ul></ul><ul><li>Anything that does I/O must expose either a synchronous or an asynchronous API </li></ul><ul><ul><li>Dictates the style of interface exposed by higher level packages, e.g. database driver, ORM </li></ul></ul>
  17. 17. API vs. Implementation <ul><li>Asynchronous, implement Node API </li></ul><ul><ul><li>Node </li></ul></ul><ul><ul><li>RhiNodeII - https://github.com/lhofhansl/RhiNodeII </li></ul></ul><ul><ul><li>SpiderNode - https://github.com/zpao/spidernode </li></ul></ul><ul><ul><li>Node.NET - https://github.com/dnewcome/Node.net </li></ul></ul><ul><li>Synchronous, implement CommonJS API </li></ul><ul><ul><li>Ringo - https://github.com/ringo/ringojs </li></ul></ul><ul><ul><li>Narwhal - https://github.com/280north/narwhal </li></ul></ul><ul><ul><li>Common Node – https://github.com/olegp/common-node </li></ul></ul>
  18. 18. Common Node <ul><li>Implements a number of synchronous CommonJS specifications on top of Node </li></ul><ul><li>Uses node-fibers </li></ul><ul><ul><li>Uses co routines or multiple stacks within the same process </li></ul></ul><ul><ul><li>not a fork or a hack </li></ul></ul><ul><li>Google's Traceur to support latest language features </li></ul><ul><li>Bridges the gap between Ringo and Node, sync and async </li></ul><ul><li>Fibers, HTTP proxy code examples & benchmarks </li></ul>
  19. 22. Platforms <ul><li>Node </li></ul><ul><ul><li>Joyent, Heroku, Nodejitsu, Nodester, Nodesocket, CloudFoundry </li></ul></ul><ul><li>Ringo </li></ul><ul><ul><li>Erbix, AppEngine & any other Java platform </li></ul></ul><ul><li>Akshell </li></ul>
  20. 23. Frameworks <ul><li>ServerJS is missing a Rails like framework </li></ul><ul><li>Asynchronous </li></ul><ul><ul><li>DIY using Connect, Express etc. with Node </li></ul></ul><ul><ul><li>Less of a problem, since Node is often used as glue </li></ul></ul><ul><li>Synchronous </li></ul><ul><ul><li>DIY using JSGI, Stick etc. with RingoJS </li></ul></ul><ul><ul><li>Lack of a solid framework more of an issue </li></ul></ul>
  21. 24. Trends <ul><li>Wider adoption </li></ul><ul><ul><li>Front end developers </li></ul></ul><ul><ul><li>First time developers - http://www.codecademy.com </li></ul></ul><ul><li>Enterprises moving off legacy systems </li></ul><ul><ul><li>Java, PHP </li></ul></ul><ul><li>New operating systems </li></ul><ul><ul><li>Windows, mobile devices (but not WebOS) </li></ul></ul>
  22. 25. Trends <ul><li>Web IDEs, XaaS </li></ul><ul><ul><li>Cloud9 – http://www.cloud9ide.com </li></ul></ul><ul><ul><li>Akshell – http://www.akshell.com </li></ul></ul><ul><li>Compile to JavaScript languages </li></ul><ul><ul><li>CoffeeScript, AltJS http://altjs.org & http://notjs.org </li></ul></ul><ul><li>Extensible systems, crowd sourced functionality </li></ul><ul><ul><li>Think WordPress plugins + platform </li></ul></ul><ul><ul><li>Locker Project http://lockerproject.org </li></ul></ul>
  23. 26. <ul><li>Thank you! </li></ul><ul><li>Questions? </li></ul><ul><li>@olegpodsechin </li></ul>

×