从现在开始,打算学习一门新的脚本语言-lua.
1.什么是lua?
a) lua1
• Lua 1.0 was implemented as a library, in less then 6000 lines of C
• “The simplest thing that could possibly work”: compiler used lex and yacc, simple stack based virtual machine, linked lists for associative arrays
• Some of the syntax still lives in the current version:
• Lua 1.1 just added a reference manual, and a cleaned-up C API
b)lua2
• From Lua 2.1 (February 1995) to Lua 2.5 (November 1996)
• Object oriented programming via delegation
• Pattern matching in the standard library
• Hooks for writing debuggers
• First users outside Tecgraf, with papers in Software: Practice and Experience and Dr. Dobb‘s Journal
• LucasArts begins using Lua in games
c)lua3
• From Lua 3.0 (September 1997) to Lua 3.2 (September de 1999)
• Anonymous functions and a restricted form of closures give better support for functional programming, which would mature in Lua 5
• Major refactoring in the source code
• The next version brings big changes to the C API, so some applications from this time still embed this version of Lua
d)lua4
• A single version, Lua 4.0, released on November 2000
• C API completely redone, using the stack model that we will see in this course
• An application can now have several independent instances of the Lua interpreter
• The standard library has been rewritten to use just the public C API, reinforcing the separation between the core and the standard libraries
e)lua5
• From Lua 5.0 (April 2003) to Lua 5.2, the current version, released December 2011
• Maturity of the language, and the release of the “Programming in Lua” book
• Several big changes: metatables, true lexical scope for anynonymous functions, the module system, coroutines, lexical environments…
• Changes in the implementation: more efficient register-based virtual machine, replacing the stack-based one, an incremental garbage collector for shorter pauses
• The implementation now has around 20.000 lines of code, 3x Lua 1.0
f)lua today
• Current license is the MIT license, free for both non-commercial and commercial use
• Open language, but closed development: new releases are still the responsibility of the three original authors
• Big community participation in the lua-l mailing list and the lua-users wiki
• A package manager, LuaRocks, and alternative Lua implementations: LuaJIT, JVM, .NET, JavaScript...
• Several frameworks for developing mobile games: Corona, Gideros, Codea, MOAI...
2.lua应用在哪里?