Opa presentation at GamesJs

402 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
402
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Opa presentation at GamesJs

  1. 1. @henri_opa http://opalang.org
  2. 2. open-source event-basedclient + server
  3. 3. #1Simple
  4. 4. 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");}
  5. 5. http://github.com/mattgu74/OpaTetris
  6. 6. http://github.com/mattgu74/OpaTetris 600
  7. 7. 1100
  8. 8. #2Cool static typing
  9. 9. Nofunction 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 usernameexists”); }; Client.goto("/login"); Error
  10. 10. Type checkingfoo = 1 + "bar"; “Types int and string are not compatible”
  11. 11. Type inference (almost complete) function foo(s) { String.length(s); } function bar(x, y) { foo(x) + y; }
  12. 12. Type inference (almost complete)int function foo(string s) { String.length(s);}int function bar(string x, int y) { foo(x) + y;}
  13. 13. element = <div> <span>{prompt({none})}</span> <span>{expr} </div> <div>{Calc.compute(expr)}</div>; Open and close tag mismatch <span> vs </div>
  14. 14. 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 }
  15. 15. 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
  16. 16. 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)
  17. 17. “Keep your eye on Opa, thenew open source language that[...] may transform Webdevelopment.” Neil McAllister“Coding in Opa is super quickand fun. I don’t think I couldhave written things faster in anyother framework.” Alok Menghrajani
  18. 18. Join device: Tokyohttp://tokyo.local:8667
  19. 19. opalang.org @opalang

×