I. Introduction:
As the most popular and free lightweight embedded scripting language, Lua is widely used in many industrial applications.ProgramHas been widely used, such as Adobe's Photoshop, and even widely used in some famous game programs, such as interstellar. In addition, Lua has many special advantages, such as simple syntax (based on process), efficient and stable (based on bytecode), Can handle complex data structures, dynamic types, and automatic memory management (based on garbage collection), so in many embedded devices and smart mobile devices, to improve Program Flexibility, scalability, and high configurability, Lua is generally used as their script engine to cope with various differences caused by different devices.
Ii. Main advantages:
1. Efficiency:
As a scripting language, Lua's efficiency is well known, so in practical applications, many large programs will considerCodeThe easy-to-change part is written in Lua. This not only does not significantly reduce the operating efficiency of the system, but also significantly improves the stability and scalability of the program.
2. Portability:
The official website provides release packages based on multiple platforms, such as Linux/Unix, windows, Symbian, and Pocket PC.
3. embeddable:
At the beginning of the language design, Lua was accurately positioned as an embedded scripting language. Therefore, Lua designers provide Programming Language Good interaction experience between them, especially in interaction with C/C ++. For other languages, such as Java and C #, you can also use Lua as its embedded script engine and perform direct interaction in the code.
4. Simple and powerful:
Despite being a procedural scripting language, Lua's designers provide Lua with a meta-mechanical ISMs mechanism, which not only gives Lua some basic object-oriented features, such as objects and inheritance, it also maintains the simple syntax features of procedural languages.
5. Small and lightweight:
In the latest version (5.2.0), Lua only contains about 20000 lines of C language code, and the size of the compiled library file is about KB, therefore, this is extremely attractive to many platforms with limited resources.
6. Free Open Source:
MIT licence allows Lua to be used in various commercial programs for free.
Iii. application scenarios:
1. In many cases, we can embed Lua directly into our applications, such as games and monitoring servers. Such an application method is completely transparent to end users of the program, but its scalability will be greatly enhanced for the program itself.
2. Regard Lua as an independent scripting language to help us develop auxiliary tools for some software products. For example, in our previous data analysis product, we wrote a Lua script to reformat the data in different formats of each user into the format that can be read by our software platform, then, load the formatted data into the database, or write it into a data analysis file that can be identified by our analysis engine. In this case, Lua is only used to normalize the file format. Subsequent operations are completed by calling our C language export function through Lua.
3. Apply Lua to the dynamic configuration of the application. For example, the display resolution of mobile smart devices or embedded devices is not standard in many cases. If we maintain a set of related configuration information for each device, this will undoubtedly increase the maintenance overhead of our program. If we submit this dynamic configuration logic to the Lua script, the flexibility of program configuration will be greatly improved. Even in this way, an application running on a mobile terminal device establishes a connection with the server before starting the main form. After the server confirms the parameters of the device, then, send the Lua script related to the display of the device to the device client. After obtaining the Lua script, the client can immediately execute the script to obtain the latest dynamic configuration information.
in the end, it is worth noting that learning Lua is an important part of the system and integrity of our knowledge, this is especially true for senior software professionals dedicated to software architecture design and software solution analysis. In many cases, if we can fully understand and control Lua, it not only increases the color of our software products, but also brings unexpected gains to our technical staff.
This is the first blog in The Lua series, and more than a dozen related blogs will be published one after another. Please keep an eye on these blogs. If you have any questions, please correct them in time. Well, let's start Lua's learning journey together. :)