RingoJS

4,396 views
4,200 views

Published on

My talk talk on RingoJS, a CommonJS-compliant JavaScript platform.

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
No Downloads
Views
Total views
4,396
On SlideShare
0
From Embeds
0
Number of Embeds
166
Actions
Shares
0
Downloads
23
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

RingoJS

  1. 1. RingoJS #cgnjs talk by  Oleg Podsechin 12.10.2010
  2. 3. Install & Run <ul><li>apt-get install default-jdk default-jre git-core ant </li></ul><ul><li>git clone git://github.com/ringo/ringojs.git </li></ul><ul><li>ant jar </li></ul><ul><li>bin/ringo </li></ul>
  3. 4. Hello World <ul><li>>> 'Hello World' </li></ul><ul><li>Hello World </li></ul>
  4. 5. Hello World, Take Two <ul><li>new   ( require ( 'ringo/httpserver' ) . Server )({   app :   function ()   {      return   { status :   200 ,               headers :   {} ,               body :   [ 'Hello World' ]} ;    } }) . start () ; </li></ul>
  5. 6. RingoJS overview <ul><ul><li>started by @hannesw  ( hns.github.com ) </li></ul></ul><ul><ul><li>uses Mozilla  Rhino </li></ul></ul><ul><ul><li>runs on the JVM </li></ul></ul><ul><ul><li>successor to Helma, HelmaNG </li></ul></ul><ul><ul><li>been in development for 10+ years </li></ul></ul><ul><ul><li>conforms to CommonJS </li></ul></ul>
  6. 7. CommonJS support <ul><ul><li>Modules/1.0, Modules/1.1 </li></ul></ul><ul><ul><li>JSGI </li></ul></ul><ul><ul><li>Binary </li></ul></ul><ul><ul><li>Filesystem </li></ul></ul><ul><ul><li>System </li></ul></ul><ul><ul><li>Unit Testing </li></ul></ul><ul><ul><li>other (mostly partial) implementations include: Akshell, CouchDB, Flusspferd, Narwhal, Persevere, RequireJS, Smart, SproutCore, node.js, v8cgi etc . </li></ul></ul>
  7. 8. RingoJS features #1 <ul><ul><li>REPL </li></ul></ul><ul><ul><li>hot reloading of modules </li></ul></ul><ul><ul><li>profiler </li></ul></ul><ul><ul><li>debugger </li></ul></ul><ul><ul><li>ringo-admin tool </li></ul></ul><ul><ul><li>runs anywhere, including AppEngine </li></ul></ul><ul><ul><li>client side CommonJS modules via ringo-modulr </li></ul></ul><ul><ul><li>JMX </li></ul></ul>
  8. 9. RingoJS features #2 <ul><ul><li>JavaScript 1.8 </li></ul></ul><ul><ul><li>Java library wrapping </li></ul></ul><ul><ul><li>runs sync and async code </li></ul></ul><ul><ul><li>continuations </li></ul></ul><ul><ul><li>introspection (via Rhino) </li></ul></ul><ul><ul><li>middleware </li></ul></ul><ul><ul><li>templating </li></ul></ul><ul><ul><li>utils </li></ul></ul><ul><ul><li>persistence abstraction layer </li></ul></ul>
  9. 10. jsonp-proxy.js #1 <ul><li>// thanks to @jasondavies var   { encode }   =  require ( 'ringo/base64' ) ,      { get }   =  require ( 'ringo/httpclient' ) ,      { Request }   =  require ( 'ringo/webapp/request' ) ,      { ByteString }   =  require ( 'binary' ) ; exports. app   =   function ( env )   {      var  req  =   new  Request ( env ) ;      var  url  =  req. params . url ,  raw  =  get ( url ) ;      return   {         status :   200 ,         headers :   { 'Content-Type' :   'text/javascript' } ,         body :   [ req. params . callback   +               '(&quot;data:&quot;+decodeURIComponent(&quot;'   +              encodeURIComponent ( raw. type )   +               '&quot;)+&quot;;base64,' ,            encode ( new  ByteString ( raw. content )) ,               '&quot;)' ]      } ; } </li></ul>
  10. 11. jsonp-proxy.js #2 <ul><li>Usage: </li></ul><ul><li>$. get ( 'http://seivadnosaj-js.appspot.com/proxy' ,   {   url :   'http://www.jasondavies.com/media/img/jason.jpg' } ,   function ( data )   {    var  img  =   new  Image () ;   img.onload  =   function ()   {      var  w  =  img. width ,  h  =  img. height ;     $ ( '#canvas' ) . attr ( 'width' ,  w ) . attr ( 'height' ,  h ) ;     context. width   =  w ;  context. height   =  h ;     context. drawImage ( img ,   0 ,   0 ,  w ,  h ) ;    } ;   img. src   =  data ; } ,   'jsonp' ) ; </li></ul><ul><li>Try it at:   http://seivadnosaj-js.appspot.com/ </li></ul>
  11. 12. Multithreaded JS (sort of) <ul><li>// run &quot;test&quot; in &quot;threads&quot; parallel threads a total of &quot;count&quot; times </li></ul><ul><li>function  parallel ( test ,  count ,  threads )   {    var  pool  =   new  java. util . concurrent . Executors . newFixedThreadPool ( threads ) ;    function  runnable ( f )   {      return   new  java. lang . Runnable ({  run :   function ()   {        try   {  f () ;   }   catch ( e )   {   }      }}) ;    }    for ( var  i  =   0 ;  i  <  count ;  i  ++ )     pool. execute ( runnable ( test )) ; } </li></ul>
  12. 13. Debugger
  13. 14. Ride - web IDE
  14. 15. RingoJS libraries <ul><ul><li>search GitHub for ringo- </li></ul></ul><ul><ul><li>ringo-admin install user/repo </li></ul></ul>
  15. 16. RingoJS performance
  16. 17. RingoJS community <ul><ul><li>active & friendly </li></ul></ul><ul><ul><li>#ringojs on Freenode IRC </li></ul></ul><ul><ul><li>#ringojs & @ringojs on Twitter </li></ul></ul><ul><ul><li>http://github.com/ringo </li></ul></ul>
  17. 18. Questions?  Comments? <ul><li>@olegpodsechin </li></ul>

×