Your SlideShare is downloading. ×
0
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Jassa la GeekMeet Bucuresti

539

Published on

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

  • Be the first to like this

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

    ×