@henri_opa




         http://opalang.org
open-source
 event-based
client + server
#1
Simple
function register_in_the_room() {
   $.ajax({
       cache: false,
       type: "POST" ,
       dataType: "json" ,
       url: "/join" ,
       data: { nick: nick } ,
       error: function () {
                                         function register_in_the_room() {
           alert("connection error”);       join(nick); onConnect();
           showConnect();                }
       } ,
       success: onConnect                function get_list_of_users() {
   });                                      users = get_user_list();
}                                           showUsers(users);
function get_list_of_users() {           }
   jQuery.get("/who", {},
   function (data, status) {
      if (status != "success") return;
      showUsers(data.nicks);
   }, "json");
}
http://github.com/mattgu74/OpaTetris
http://github.com/mattgu74/OpaTetris




       600
1100
#2
Cool static
  typing
No
function createUser(username, password) {
   match (findUser(username)) {




                                                Type errors at
       case {none}:
          user =
             { username: username,




          Code
               fullname: "",
               password: Crypto.Hash.sha2
(password) };



                                                compile time?
          saveUser(user);




                                                                 Yes
       default: displayMessage(“This username
exists”);
    };
    Client.goto("/login");




                                                                       Error
Type checking


foo = 1 + "bar";
          “Types int and string are
               not compatible”
Type inference
   (almost complete)



  function foo(s) {
     String.length(s);
  }

  function bar(x, y) {
     foo(x) + y;
  }
Type inference
         (almost complete)



int function foo(string s) {
   String.length(s);
}

int function bar(string x, int y) {
   foo(x) + y;
}
element =
   <div>
      <span>{prompt({none})}</span>
      <span>{expr}
   </div>
   <div>{Calc.compute(expr)}</div>;




 Open and close tag mismatch
       <span> vs </div>
case {some: 13}:   #status = "Enter";
callback(get());
case {some: 37}:   #status = "Left";
move({lef});
case {some: 38}:   #status = "Up";
move({up});
case {some: 39}:   #status = "Right";
move({right});
        First type: { lef }
            Second type:
      { left } or { right } or
           { rightmost } or
          { up } or { down }
previous = Dom.get_content(#precaret);
#precaret = String.sub(0,
String.lenght(previous) - 1,
previous);
#postcaret += String.get(String.length
(previous) - 1, previous);



      No field ‘lenght’ found.
         Most probable field:
        length: string -> int
previous = Dom.get_content(#postcaret);
#postcaret = String.sub(1,
String.length(previous) - 1, previous);
#precaret =+ String.get(previous);




        String.get is a string
      function(int, string) but
          application uses it
          as function(string)
“Keep your eye on Opa, the
new open source language that
[...] may transform Web
development.”   Neil McAllister




“Coding in Opa is super quick
and fun. I don’t think I could
have written things faster in any
other framework.”        Alok Menghrajani
Join device: Tokyo

http://tokyo.local:8667
opalang.org
 @opalang

Opa presentation at GamesJs

  • 1.
    @henri_opa http://opalang.org
  • 3.
  • 4.
  • 5.
    function register_in_the_room() { $.ajax({ cache: false, type: "POST" , dataType: "json" , url: "/join" , data: { nick: nick } , error: function () { function register_in_the_room() { alert("connection error”); join(nick); onConnect(); showConnect(); } } , success: onConnect function get_list_of_users() { }); users = get_user_list(); } showUsers(users); function get_list_of_users() { } jQuery.get("/who", {}, function (data, status) { if (status != "success") return; showUsers(data.nicks); }, "json"); }
  • 7.
  • 8.
  • 10.
  • 11.
  • 12.
    No function createUser(username, password){ match (findUser(username)) { Type errors at case {none}: user = { username: username, Code fullname: "", password: Crypto.Hash.sha2 (password) }; compile time? saveUser(user); Yes default: displayMessage(“This username exists”); }; Client.goto("/login"); Error
  • 13.
    Type checking foo =1 + "bar"; “Types int and string are not compatible”
  • 14.
    Type inference (almost complete) function foo(s) { String.length(s); } function bar(x, y) { foo(x) + y; }
  • 15.
    Type inference (almost complete) int function foo(string s) { String.length(s); } int function bar(string x, int y) { foo(x) + y; }
  • 16.
    element = <div> <span>{prompt({none})}</span> <span>{expr} </div> <div>{Calc.compute(expr)}</div>; Open and close tag mismatch <span> vs </div>
  • 17.
    case {some: 13}: #status = "Enter"; callback(get()); case {some: 37}: #status = "Left"; move({lef}); case {some: 38}: #status = "Up"; move({up}); case {some: 39}: #status = "Right"; move({right}); First type: { lef } Second type: { left } or { right } or { rightmost } or { up } or { down }
  • 18.
    previous = Dom.get_content(#precaret); #precaret= String.sub(0, String.lenght(previous) - 1, previous); #postcaret += String.get(String.length (previous) - 1, previous); No field ‘lenght’ found. Most probable field: length: string -> int
  • 19.
    previous = Dom.get_content(#postcaret); #postcaret= String.sub(1, String.length(previous) - 1, previous); #precaret =+ String.get(previous); String.get is a string function(int, string) but application uses it as function(string)
  • 22.
    “Keep your eyeon Opa, the new open source language that [...] may transform Web development.” Neil McAllister “Coding in Opa is super quick and fun. I don’t think I could have written things faster in any other framework.” Alok Menghrajani
  • 23.
  • 24.