• Like
Jassa la GeekMeet Bucuresti
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Jassa la GeekMeet Bucuresti

  • 515 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
515
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • SpiderMonkey C API created by Mozilla Rhino JAVA API created by Mozilla V8 C++ API created by Google KJS ->WebKit used in Safari
  • SpiderMonkey C API created by Mozilla Rhino JAVA API created by Mozilla V8 C++ API created by Google KJS ->WebKit used in Safari

Transcript

  • 1. The One Script ...language, to rule them all...
  • 2. JaSSa JavaScript on ServerSide Alexandru NOVAC [email_address] Zitec.com CTO & Founding Partner * Click here if you do not want to see more ads
  • 3. JavaScript Trivia
    • Creator:
    • - Brendan Eich, Mozilla CTO
    •  
    • Previous aliases:
    • - Mocha
    • - LiveScript
    •  
    • DoB:
    • - work started in '95
    • - available since '96 
    • (Netscape Navigator 2.0)
    • ECMA Standard:
    • - 1997 - got an ugly code name, (mostly thanks to Microsoft): ECMAScript 
    Some JavaScript Offsprings:   - Mozilla's SpiderMonkey    - Microsoft's JScript   - Adobe's ActionScript 3   - Nokia's (formerly Trolltech's) QtScript   - Apple's Safari uses JavaScriptCore   - Last but definitely not least: Google's V8 Engine (1337)
  • 4. ServerSide JavaScript
    • Why Oh Why?
      • Web GUI is mostly based on HTML, CSS AND JavaSscript
    •  
      •   Flash GUI is now using ActionScript 3 (ECMAScript)
    •  
      • Lots of server-side options: PHP, Python, Ruby, ASP.NET etc.
    •  
      • Why use another language?
      • Why duplicate code (eg. form validations)
    • Previous Art
      • jaxer (Mozilla + SpiderMonkey)
    •  
      • jslibs (SpiderMonkey DirectX) 
    •  
      • mod_js
    •  
      • jsext
    •  
      • v8cgi  (V8 CGI, FastCGI, apache module)
  • 5. Tactical Analysis
    • Advantages:
    •  
      • a language  well known  to decent web developers (?) 
    •  
      • ability to use the same code on server-side and client-side
    •  
      • smooth communication via JSON  
    •  
      • built-in XML support through E4X (SpiderMonkey only)
    •  
      • Speed (will see later on)
    • Drawbacks:
      • early stage 
    •  
      • various implementations that are very different
    •  
      • no unified set of classes/interfaces to access external libraries like mysql, pgsql, curl etc. 
      • scripts wrote for one implementation won't work on another :(
  • 6. The JavaScript Engine
    • Mozilla's SpiderMonkey & Google's V8
      • language constructs
      • basic types functionality ( integers, strings, arrays )
      • the ability to embed it into your own application
      • the ability to expose functionality from the application to the scripting environment.
  • 7. JASSA Goals <3
    • Covered or initiated:
      • access to the server environment
      • access to the HTTP request and response
      • expose various libraries (MySQL, CURL etc)
      • make it easy to create extensions
      • group features into namespaces (db, net, system)
    • To Do List:
      • expose system functionality (sockets, system calls)
      • performance!
  • 8. Accessing a MySQL DB
    •  var print = jassa.response.append;
    • var db = new jassa.MySQL();
    • db.connect( 'localhost' , 'root' , '' , 'jassa' );
    • var contacts = db.getAll( 'SELECT * FROM contacts' , true );
    • print( '<table> ' );
    • for( var idx in contacts ) {
    • var contact = contacts[idx];
    • print( '<tr>' );
    • for( var idxo in contact ) {
    • print( '<td>' + contact[idxo] + '</td>' );
    • }
    • print( '</tr> ' );
    • }
    • print( '</table> ');
  • 9. Using CURL & XML
    • var print = jassa.response.append;
    • print( 'Retrieving BNR Exchange Rates via CURL...<br /> ' );
    • var c = new jassa.CURL();
    • c.setURL( 'http://www.bnr.ro/nbrfxrates.xml' );
    • c.perform();
    • var rate = new XML( c.response.body );
    • var ns = new Namespace( 'http://www.bnr.ro/xsd' );
    • var eur = rate..ns::Rate.(@currency == &quot;EUR&quot;);
    • print( '1EUR = ' + eur + 'RON' );
  • 10. How it Works
  • 11. JASSA Performance
  • 12. JASSA Performance
  • 13. K.Thx.Bye.
    • Many thanks to:
      • Everyone that made JavaScript possible
      • GoogleDocs which made this presentation possible
    CAN I HAS QUESTIONS? #followfriday @acidtrix & @zitec on Twitter