Opa hackathon
Upcoming SlideShare
Loading in...5
×
 

Opa hackathon

on

  • 843 views

 

Statistics

Views

Total Views
843
Views on SlideShare
836
Embed Views
7

Actions

Likes
2
Downloads
3
Comments
0

4 Embeds 7

https://si0.twimg.com 2
http://www.linkedin.com 2
http://www.scoop.it 2
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Opa hackathon Opa hackathon Presentation Transcript

  • HackathonWiFi pass: groundfloorsvDownload Opa 1.0.5 at opalang.orgwhile bandwidth lasts
  • Problem #1
  • Problem #1 Memcache FrameworkWeb Browser Web Browser Web Browser Web Browser Web Web Browser Web Web Web Browser Web Browser Server Language Language Web Browser Web Browser Server Server Language Web Browser Language Web Browser Web Browser Web Server Web Browser Web Browser Web Browser Web Browser Web Browser Web Browser Web Browser ORM Web Browser Web Browser Web Browser Web Browser Web Browser Web Browser Database Web Browser Web Browser Database Database Web Browser Web Browser Database Database Web Browser Web Browser Web Browser Web Browser Database Web Browser
  • Universal Language
  • Universal Language
  • Universal Language
  • Universal Language
  • Universal Language
  • Problem #2
  • This is JavaScript> 9 + 5 + “ customers” 14 customers> “Customers: ” + 9 + 5 Customers: 95
  • < ?
  • This is JavaScript switch (x) { case 0:if (x == 0) retry(); retry(); break;else if (x == 1) case 1: success(); success();else break; error(); default: error(); }
  • x = “0” switch (x) { case 0:if (x == 0) retry(); retry(); break;else if (x == 1) case 1: success(); success();else break; error(); default: error(); } retry error
  • This is JavaScript [] + [] [] + {} {} + [] {} + {} (@garybernhardt)
  • This is JavaScript [] + [] = ““ [] + {} = {} {} + [] = 0 {} + {} = NaN (@garybernhardt)
  • Project Launch: June 21st 2011 Man-years: 60+
  • Code automation
  • AJAX/COMETCode automation Non-blocking Event-driven
  • Code verification
  • Code verification
  • Code verification
  • Live Demo
  • JS-like syntaxHTML first classEvent-driven
  • Code verification
  • Code verification
  • Code verification
  • Live Demo
  • mo De de ive hiL o T // try different typing errors: // show errors in the terminal // show type infered function foo(s) { String.length(s); } function bar(x, y) { foo(x) + y; // foo("hello") + y; // foo(x) + y + "hello"; } _ = bar("hello", 2) //_ = bar(1, 2)
  • Type checkingfoo = 1 + "bar"; “Types int and string are not compatible”
  • Type inferencefunction foo(s) { String.length(s);}function bar(x, y) { foo(x) + y;}
  • Type inferenceint function foo(string s) { String.length(s);}int function bar(string x, int y) { foo(x) + y;}
  • Strong static typing without any hassle.
  • A single language
  • Client and server // Will be on server side: function db_update(value) { /mydb/counter <- value } // Will be on client-side: function dom_update(value) { #counter = value }
  • Client and server function update(value) { /mydb/counter <- value; #counter = value }
  • Client and server function init() { #counter = /mydb/counter }
  • Transparent distributionbetween client and server
  • Precise control
  • Live Demo
  • // a dangerous functionprotected function dangerous() { 42 }// a bit of codefunction code() { dangerous() }// an innocent bit of client codeclient function malicious() { code() }
  • // database operations are protected BY DEFAULTdatabase mydb { string /personal_data}function code() { /mydb/personal_data }// Try those different directives:// protected// server -> meaning less// terminal error without «protected» on codeclient function malicious(code) { code() }
  • Precise control client server exposed protected sync async public private
  • Strong database mapping
  • Data declarationtype user = { string mail, int age, list(string) comments}database dbname @mongo { user /user[{mail}] // primary key int /user/age = 18 // default value}
  • Data queries/db/col[name == v; order -score; limit 50]; == skip in [e1, e2] != limit or < order and <= not > >=
  • Data queries/db/col[n > 10 and n < 20]; opause dbdb.col.find( {$and : [{ n : { $gt : 10 } }, { n : { $lt : 20 } } ]}) mongoDB shell
  • Data updates/db/path[id == id] <- { n += 1, l <+ e } n += 800 l pop n++ l shift n-- l <+ e n : v l <++ [e1, e2, e3]
  • Transparent mapping between db and code values. Type checking included. (even for mongoDB)
  • Non-blocking
  • function fib(n) { if (n == 0) 0 else if (n == 1) 1 else fib(n-1) + fib(n-2)}
  • mo / / D e mo n s t ra te a c li en t d o esn ’ t b l ock an o the r De de / / S e ve r a l c om pu ta ti on at the tim e ar e po s sib le ive hi / / T a lk a b ou t CP SL o T i m po r t s t d li b. th em es .b oot s tra p / / n a iv e f ib on ac ci f u nc t io n f ib (i d, n ) { if (n = = 0 ) 0 el s e i f (n = = 1) 1 el s e f ib ( n - 1) + f ib (n -2 ) } s e rv e r f u n ct io n ac ti on (_) { # re s ul t = f ib (4 0) } f u nc t io n p ag e( ) { <d i v c l a ss =" we ll "> <b u t t on c la ss =" bt n" on c lic k ={a c tio n }>C o mpute</button> <h 2 i d= #r es ul t cl as s=" w ell " /> </ d iv > } S e rv e r. s t a rt ( Se r ve r . h tt p, { ~ pa g e , t it le : "H el lo f ibo " } )
  • opalang.org @opalang @henri_opa
  • opa create myapp make run
  • Windows: bit.ly/O1JiKcLinux, Mac: sudo easy_install pip && sudo pip install dotcloud git clone https://github.com/dotcloud/opa-on-dotcloud dotcloud create myapp dotcloud push myapp opa-on-dotcloud