Lua Tutorial programming language

Lua is an embeddable scripting language originally developed at Tecgraf, PUCRio in 1993 and now widely used in the interactive entertainment industry1. Its main goals are to be simple, efficient, portable and lightweight. The objective of this project was to improve the performance of the Lua programming language interpreter by adding a just-in-time (JIT) compiler to the standard run-time environment.

Although it is among the fastest scripting languages, Lua is still approximately a factor of 20 slower than C in the majority of benchmarks [?, ?]. There is still plenty of room for improvement. Admittedly, the performance of the standard Lua virtual machine (VM) is adequate for tasks such as configuration or for use as a ‘glue’ language, but high performance and efficiency are important in games and interactive applications

Si vous rencontrez des erreurs liées au téléchargement de votre document, n'hésitez pas à nous contacter.

Télécharger Lua Tutorial programming language

Lua Tutorial programming language
Téléchargement12
FormatIcon
Taille644 KO

Formation adaptées à votre besoins, tous les livres pdf et cours LUA , cours développement LUA , projet de fin d'études.., peuvent être lus en ligne et vous pouvez télécharger la plupart d'entre eux directement sur votre ordinateur, liseuse, tablette ou smartphone sous divers formats : DOC, PDF, RAR, ZIP.., vous pouvez maintenant télécharger gratuitement ce document -Lua Tutorial programming language-, pour améliorer vos connaissances en développement LUA, tutoriel Lua, manuel Lua français, quel langage de programmation pour une application mobile ?, cours de base pour apprendre a programmer avec lua ? plus de rapport de stage et projet de fin d'étude en pdf. N'hésitez pas à télécharger nos didacticiels et nos documents guides et à apprendre la joie de l'apprentissage libre.

formation LUA

Coercion of Types :

String and number types are automatically converted between each other: whenever a string is used in a context where a number is expected, the string is converted into a number, and vice versa. An error is raised if a string cannot be converted into a number, as demonstrated in the interactive Lua session in Figure 1.3. This behaviour must be retained by the JIT compiler to ensure consistent execution of arbitrary Lua programs.

Metamethods

Another powerful concept in Lua is the alteration of the semantics for userdata and table accesses through using metamethods. Metamethods allow programs to overload certain operations on tables and userdata objects. Each overloaded object has a metatable of functions (metamethods) associated with it. The metamethods are associated with events, which occur when operations such as addition and comparisons are performed on the object. This can even be used to implement object-oriented mechanisms [?].

Libraries

The standard Lua distribution includes a set of core libraries for performing I/O, math and string operations; it is straightforward to add extra user-defined libraries, written either in C or Lua. These extra libraries can be dynamically loaded at runtime. It is interesting to note that the majority of Java’s standard libraries are written in Java, whereas Lua’s standard libraries are mainly written in C for speed. With the addition of the JIT compiler, it may be feasible to rewrite many of Lua’s standard libraries in Lua.

Areas of Optimisation

Lua’s internal compiler is executed every time a Lua source file is loaded. In order to be as fast and compact as possible, it does not heavily optimise the intermediate bytecode it generates. Some additional inexpensive peephole optimisations could still be added, in particular constant folding, which refers to the evaluation at compile time of expressions whose operands are known to be constant. For instance, a and b or c is a common Lua idiom, used to simulate a ternary operator. When b is a constant, a redundant test on b is generated by the compiler. These static compiler optimisations are outside the scope of this project, and could be investigated as a possible extension.

Submodules and Packages :

Lua allows module names to be hierarchical, using a dot to separate name levels. For instance, a module named mod.sub is a submodule of mod. Accordingly, you may assume that module mod.sub will define all its values inside a table mod.sub, that is, inside a table stored with key sub in table mod. A package is a complete tree of modules; it is the unit of distribution in Lua. When you require a module called mod.sub, require queries first the table package.loaded and then the table package.preload using the original module name “mod.sub” as the key; the dot has no significance whatsoever in this search.

What About Lua? :

Yet another scripting language ● Goals ● Emphasis on scripting ● Portable ● Small ● Simple ● Efficient

Scripting

Scripting language x dynamic language ● scripting emphasizes inter-language communication ● Program written in two languages ● a scripting language and a system language ● System language implements the hard parts of the application ● algorithms, data structures ● little change ● Scripting glues together the hard parts ● flexible, easy to change

Lua is fast :

Lua has a deserved reputation for performance. It is an aspiration of other scripting languages to claim to be "as fast as Lua". Several benchmarks show Lua as the fastest language in the realm of interpreted scripting languages. Lua is fast not only in fine-tuned benchmark programs, but in real life too. A substantial fraction of large applications have been written in Lua.

Lua is embeddable :

Lua is a fast language engine with small footprint that you can embed easily into your application. Lua has a simple and well documented API that allows strong integration with code written in other languages.

Lua is powerful (and simple) :

Lua provides meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways.

What is LuaSDL :

LuaSDL is a glue/abstraction layer of Lua on SDL & Ext Libs (SDL_Mixer, SDL_Image, SDL_net, and SDL_ttf). This architecture allows Game content developers to use SDL interfaces in Lua scripts. Below figure depicts the S/W data flow in Lua Abstraction Framework. There are various components which executes the control flow from native SDL to Lua Abstraction layer as follows: 1. Script Game Launcher: It is responsible to execute the Lua Script Game. 2. Script game contents: It includes all the game resources. Game script calls the APIs of Lua Abstraction layer & so provides similar functionality to end user. 3. Lua Abstraction Layer: This layer is basically wrapper over the corresponding native Library. Like for SDL & SDL ext Libs, it has Lua based data types & APIs support which has interaction with respective native data types & APIs. 4. Native SDL & SDL ext Libs: Framework consists of both Native & Lua Abstraction layer to provide integrated solution for product development.

Conclusions :

Throw exceptions in situations which usually can't be handled locally by parent stack frame ● Use try-except construct for exception handling ● Throw tables instead of strings ● Enumerate errors as part of API ● Fixing pcall/coroutine problem is important ● Standard interface for inheritance testing would be useful

cours développement LUA

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *