Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

    • Lua 是强大的高效的轻量级嵌入式**脚本语言**。
    • 支持过程式面向对象式函数式数据驱动式编程与数据描述

    Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with a generational garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

    • Lua 是综合了强大的数据结构描述的简单函数式语法,这是基于关联数组可扩展语义基础上的
    • Lua 是动态类型的,通过使用基于寄存器的虚拟机解释字节码来运行
    • 有可以进行分代垃圾收集自动内存管理
    • 综上有点使其成为配置、脚本编写和快速原型设计的理想选择

    Lua is implemented as a library, written in clean C, the common subset of Standard C and C++. The Lua distribution includes a host program called lua, which uses the Lua library to offer a complete, standalone Lua interpreter, for interactive or batch use. Lua is intended to be used both as a powerful, lightweight, embeddable scripting language for any program that needs one, and as a powerful but lightweight and efficient stand-alone language.

    • Lua是一个,以纯净的 C 来写 (标准 C 和 C++ 的共有子集)
    • Lua 发行版包括了一个叫做 Lua主程序
      • 使用 Lua 库去提供了一个完整的,独立的 Lua 解释器
      • 交互或者批处理使用
    • 不仅可以嵌入程序进行辅助;同时也是一个轻量化高效独立语言

    As an extension language, Lua has no notion of a “main” program: it works embedded _in a host client, called the _embedding program or simply the host. (Frequently, this host is the stand-alone lua program.) The host program can invoke functions to execute a piece of Lua code, can write and read Lua variables, and can register C functions to be called by Lua code. Through the use of C functions, Lua can be augmented to cope with a wide range of different domains, thus creating customized programming languages sharing a syntactical framework.

    • 作为扩展语言,没有 “主” 程序概念
    • 嵌入在主机客户端进行工作,可以被叫做嵌入程序或简单地称为主机程序
      • 这种主机程序一般都为独立 Lua 程序,而非嵌入到其他程序中的辅助程序
    • 主机程序可以
      • 调用函数来执行一段 Lua 代码
      • 可以读写 Lua 变量
      • 可以注册要被 Lua 代码调用的 C 函数
    • 通过调用 C 语言函数,可以对 Lua 进行扩展
      • 以应对广泛的不同领域
      • 从而创建共享语法框架的定制编程语言

    Lua is free software, and is provided as usual with no guarantees, as stated in its license. The implementation described in this manual is available at Lua’s official web site, www.lua.org.

    Like any other reference manual, this document is dry in places. For a discussion of the decisions behind the design of Lua, see the technical papers available at Lua’s web site. For a detailed introduction to programming in Lua, see Roberto’s book, Programming in Lua.

    • 官方文档很枯燥 (这是废话)
    • 推荐书籍: Programming in LuaRoberto 作者书写