Lua Application Programming
https://hisham.hm/papers/talks/hisham-lap-luaconf2017.pdf
用Lua开发应用程序不仅仅要学习语言本身,包括运行环境,开发工具和部署工具等等。
A lot goes into writing an application:
- The language itself. Which version of Lua? (Does it matter?)
- The language environment. Platforms? Libraries? Frameworks?
- The development tools.Editors? Static checkers? Testing? CI?
- The deployment. How will users install and run your program?
如何让App更清晰简单呢?模块化!每个模块都可以单独拎出来做成lib, 但是不要这条路上走得太远。 另外做成lib思考方式可以让你避免使用太多技巧,这些技巧使得代码没有办法组合使用。
Library-oriented design:
- Structure as much of your application as possible as libraries:
- Split concerns into libraries. Favor reusing existing ones
- Don’t go overboard writing libraries. or you’ll never get to the app!
- Helps coding for collaboration – Well-defined programming interfaces – Well-defined responsibility boundaries
- Helps taming complexity – Divide and conquer – Each piece is small and simple!
Libraries avoid tricks:
- The library mindset helps you avoid tricks
- Avoid whenever possible: – Global metatable magic – Global variables – Global environment tricks – Debug library tricks – Implicit coroutine use
- These things do not compose