Ce diaporama a bien été signalé.

Web development with Lua and Sailor @ GeeCon 2015

1

Partager

1 sur 51
1 sur 51

Web development with Lua and Sailor @ GeeCon 2015

1

Partager

Télécharger pour lire hors ligne

Lua is a very fast and powerful scripting language that can be easily embeddable. It can be used to develop robust applications and has been shining in industries like game development, for example. Lua is also an excellent tool as a general purpose language. However, it's use in web development, despite its great potential and incredible benchmarks, needs to be more widespread. Having had experience as a web programmer, and aiming to learn more about this language, I started a marathon that produced Sailor 0.1, a web MVC framework completely written in Lua after only ten days. Once the quest was completed, the feedback was so interesting that I continued the development. Sailor keeps growing each day, also with the help of contributors. This talk presents the beginnings of Sailor framework, a comparison with other existing tools in Lua, the current stage of Sailor's development today, the official announcement of version 0.3 (Jupiter). This presentation also intends to start a debate on what we can do to spread the idea of using more Lua in web development.

Lua is a very fast and powerful scripting language that can be easily embeddable. It can be used to develop robust applications and has been shining in industries like game development, for example. Lua is also an excellent tool as a general purpose language. However, it's use in web development, despite its great potential and incredible benchmarks, needs to be more widespread. Having had experience as a web programmer, and aiming to learn more about this language, I started a marathon that produced Sailor 0.1, a web MVC framework completely written in Lua after only ten days. Once the quest was completed, the feedback was so interesting that I continued the development. Sailor keeps growing each day, also with the help of contributors. This talk presents the beginnings of Sailor framework, a comparison with other existing tools in Lua, the current stage of Sailor's development today, the official announcement of version 0.3 (Jupiter). This presentation also intends to start a debate on what we can do to spread the idea of using more Lua in web development.

Plus De Contenu Connexe

Livres associés

Gratuit avec un essai de 14 jours de Scribd

Tout voir

Web development with Lua and Sailor @ GeeCon 2015

  1. 1. Web development with Lua Programming Language Introducing Sailor, a web MVC framework in Lua Etiene Dalcol @etiene_d
  2. 2. @etiene_d
  3. 3. Sailor!
 http://sailorproject.org Web development with Lua @ GeeCON 2015 @etiene_d
  4. 4. Lua Ladies
 http://lualadies.org Web development with Lua @ GeeCON 2015 @etiene_d
  5. 5. Google Summer of Code LabLua Web development with Lua @ GeeCON 2015 @etiene_d
  6. 6. Web development with Lua @ GeeCON 2015 @etiene_d
  7. 7. Advantages Web development with Lua @ GeeCON 2015 @etiene_d
  8. 8. Web development with Lua @ GeeCON 2015 @etiene_d
  9. 9. better reasons • It looks cool (I heard you could make games with it) Web development with Lua @ GeeCON 2015 @etiene_d
  10. 10. better reasons • It looks cool (I heard you could make games with it) • It’s made in my home country (In my university to be more precise) Web development with Lua @ GeeCON 2015 @etiene_d
  11. 11. better reasons • It looks cool (I heard you could make games with it) • It’s made in my home country (In my university to be more precise) • It’s easy to learn Web development with Lua @ GeeCON 2015 @etiene_d
  12. 12. ? ? ? ? ? ?Web development with Lua @ GeeCON 2015 @etiene_d
  13. 13. Lua on the web • Early stage • cgilua ~ 1995 • Kepler Project ~ 2003 Web development with Lua @ GeeCON 2015 @etiene_d
  14. 14. “ I have myself developed Web sites with pure C++, Java, C#, PHP, and Python. The easiest way to go was definitely Python. If the libraries existed, Lua would be not quite as easy to use as Python, but probably quite a bit more efficient; I think it would become my first choice... if the libraries existed.” Michael Gogins “ Recently there was some discussion about mod_lua on the Apache developers mailing list. I mentioned there that I feel Lua could replace PHP as the number one web scripting language if mod_lua were stable (i.e. not still in beta) and it were implemented well (not making some of PHP's mistakes such as putting everything in the global scope with no consistent naming or parameter schemes). I've wanted to use Lua for all the things I currently use PHP for ever since I discovered it.” Rena Web development with Lua @ GeeCON 2015 @etiene_d
  15. 15. Web development with Lua @ GeeCON 2015 @etiene_d
  16. 16. Web development with Lua @ GeeCON 2015 @etiene_d
  17. 17. Web development with Lua @etiene_d
  18. 18. Web development with Lua @ GeeCON 2015 @etiene_d
  19. 19. Web development with Lua @ GeeCON 2015 @etiene_d
  20. 20. Why? Web development with Lua @ GeeCON 2015 @etiene_d
  21. 21. Web development with Lua @ GeeCON 2015 @etiene_d
  22. 22. Servers • Apache: mod_lua • Nginx: OpenResty Web development with Lua @ GeeCON 2015 @etiene_d
  23. 23. Servers Web development with Lua @ GeeCON 2015 @etiene_d • Apache: mod_lua • Nginx: OpenResty
  24. 24. Servers • Apache: mod_lua • Nginx: OpenResty • Xavante • Others Web development with Lua @ GeeCON 2015 @etiene_d
  25. 25. Frameworks • Orbit (2007) Least known No significant updates since 2010 MVC Web development with Lua @ GeeCON 2015 @etiene_d
  26. 26. Frameworks • Orbit (2007) Least known No significant updates since 2010 MVC • Luvit (2011) Most popular Intense development node.js port 2-4x faster Web development with Lua @ GeeCON 2015 @etiene_d
  27. 27. Frameworks • Lapis (2012) Intense development Moonscript and Lua Very well documented Templater OpenResty only Not MVC Web development with Lua @ GeeCON 2015 @etiene_d
  28. 28. Frameworks • Lapis (2012) Intense development Moonscript and Lua Very well documented Templater OpenResty only Not MVC • Others Complicated, abandoned, poorly documented, license issues or I never heard about it... Web development with Lua @ GeeCON 2015 @etiene_d
  29. 29. Sailor! Web development with Lua @ GeeCON 2015 @etiene_d
  30. 30. Sailor! Web development with Lua @ GeeCON 2015 @etiene_d
  31. 31. Sailor! Web development with Lua @ GeeCON 2015 @etiene_d
  32. 32. Sailor! 0.1 (Venus) 0.2 (Mars) Web development with Lua @ GeeCON 2015 @etiene_d
  33. 33. What exactly is Sailor? • It’s an MVC web framework • Completely written in Lua • Compatible with Apache (mod_lua), Nginx (OpenResty), Mongoose, Xavante and Lwan • Compatible with Linux, Windows and Mac • Compatible with different databases • MIT License • Pre alpha v0.2 (Mars) • 0.3 (Jupiter) will be released TODAY! Web development with Lua @ GeeCON 2015 @etiene_d
  34. 34. Web development with Lua @ GeeCON 2015 @etiene_d
  35. 35. What (else) is cool about Sailor? • Routing and friendly URLs • Session, cookies, include, redirect… • Lua Pages parsing • Mail sending • Simple Object Relational-Mapping • Validation (valua) • Basic login and authentication modules • Form generation • Themes (Bootstrap integration out of the box) • App generator (Linux and Mac only) • Model and CRUD generator Web development with Lua @ GeeCON 2015 @etiene_d
  36. 36. • Routing and friendly URLs • Session, cookies, include, redirect… • Lua Pages parsing • Mail sending • Simple Object Relational-Mapping • Validation (valua) • Basic login and authentication modules • Form generation • Themes (Bootstrap integration out of the box) • App generator (Linux and Mac only) • Model and CRUD generator • Lua at client What (else) is cool about Sailor? Web development with Lua @ GeeCON 2015 @etiene_d
  37. 37. Not so great things • It’s still in early development • Things are changing fast • It lacks features • Documentation Web development with Lua @ GeeCON 2015 @etiene_d
  38. 38. How to get Sailor! $ luarocks install sailor $ sailor_create ‘My App’ /var/www $ cd /var/www/my_app $ lua start-server.lua Web development with Lua @ GeeCON 2015 @etiene_d
  39. 39. Web development with Lua @ GeeCON 2015 @etiene_d
  40. 40. How to get Sailor! $ luarocks install sailor $ sailor_create ‘My App’ /var/www $ cd /var/www/my_app $ lua start-server.lua $ luarocks install luasql-mysqlOptional Web development with Lua @ GeeCON 2015 @etiene_d
  41. 41. /conf /controllers /models /pub /runtime /themes /views App structure Web development with Lua @ GeeCON 2015 @etiene_d
  42. 42. Example! -- /controllers/site.lua local site = {} function site.index(page) local msg = “Hello World” page:render(‘index’, { msg = msg } ) end function site.notindex(page) page:write(“I’m different!”) end return site Web development with Lua @ GeeCON 2015 @etiene_d
  43. 43. Example! <!-- /views/site/index.lp --> <p> A message from the server: <?lua page:print(msg) ?> <br/> The message again: <%= msg %> <!-- same thing as above —> </p> Web development with Lua @ GeeCON 2015 @etiene_d
  44. 44. Example! Web development with Lua @ GeeCON 2015 @etiene_d
  45. 45. Example! <?lua@server -- Code here runs on the server ?> <?lua -- Same as above ?> <?lua@client -- Runs at the client ?> <?lua@both -- Runs at the server and the client ?> <?lua@both another_msg = “Another message” ?> <?lua page:print(another_msg) ?> <?lua@client js.window.alert(another_msg) ?> Web development with Lua @ GeeCON 2015 @etiene_d
  46. 46. Example! Web development with Lua @ GeeCON 2015 @etiene_d
  47. 47. Example! local user = {} local v = require “valua” -- validation module user.attributes = { { id = “safe” }, { name = v:new().not_empty() } } user.db = { key = ‘id’, table = ‘users’ } user.relations = { posts = { -- u.posts relation = “HAS_MANY”, model = “post”, attribute = “author_id” } } return user Web development with Lua @ GeeCON 2015 @etiene_d
  48. 48. Example! -- /controllers/site.lua local site = {} function site.index(page) local User = sailor.model(‘user’) local u = User:new() u.name = ‘Arnold’ local msg if u:save() then msg = ‘Success’ else msg = table.unpack(u.errors) end local users = User:find_all() page:render(‘index’, { msg = msg, users = users } ) end return site Web development with Lua @ GeeCON 2015 @etiene_d
  49. 49. sailorproject.org github.com/Etiene/sailor dalcol@etiene.net @etiene_d
  50. 50. Example! Web development with Lua @ GeeCON 2015 @etiene_d
  51. 51. sailorproject.org github.com/Etiene/sailor dalcol@etiene.net @etiene_d

×