1 / 34

Lua: The Programming Language

Lua: The Programming Language. Some Things that Need to be Said. Because of increasing demand for customizable applications, the trend nowadays is to split complex systems into two parts: Kernel & Configuration. Kernel implements the basic classes and objects of the system

conner
Download Presentation

Lua: The Programming Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lua: The Programming Language

  2. Some Things that Need to be Said • Because of increasing demand for customizable applications, the trend nowadays is to split complex systems into two parts: Kernel & Configuration

  3. Kernel implements the basic classes and objects of the system Usually written in a compiled, statically typed language Configuration connects the basic classes and objects to give the application its final shape Usually written in an interpreted, flexible language Kernel VS Configuration

  4. Configuration Languages • Range from simple languages for selecting preferences (usually implemented as parameter lists in command lines or as variable-value pairs read from configuration files) to embedded languages

  5. Embedded Languages • Used for extending applications with user-defined functions based on primitives provided by the application • Can be quite powerful being sometimes simplified versions of mainstream programming languages – extension languages

  6. Extension Languages • Are called such because the allow the extension of the basic kernel semantics with new user defined capabilities • Only work embedded in a host client, called the host program

  7. Requirements for Extension Languages • need good data description facilities, since they are frequently used as configuration languages • should have a clear and simple syntax, because their main users are not professional programmers

  8. More Requirements for Extension Languages • should be small, and should have a small implementation; otherwise, the cost of adding the library to an application may be too high • should also be extensible. Unlike conventional languages, extension languages are used in a very high abstraction level, adequate for interfacing with users in quite diverse domains

  9. An Overview of Lua • An extensible procedural language with data description facilities • It is used to extend programs written in a full programming language

  10. An Overview of Lua • Incorporates facilities common to most procedural languages – control structures (whiles, ifs, etc.), assignments, subroutines, and infix operators – but abstracts out any facilities specific to any particular domain

  11. An Overview of Lua • Lua is not a stand-alone language thus it needs to be initialized and calledfrom another language like C and C++ • In its design, the creation of a few meta mechanisms allow programmers to implement dynamic associative arrays, reflexive facilities, and fallbacks

  12. Dynamic Associative Arrays • Directly implement a multitude of data types like ordinary arrays, records, and sets • Lever the data description power of Lua by means of constructors

  13. Reflexive Facilities • Allow the creation of highly polymorphic parts • Persistence and multiple name spaces are not present in Lua, but can be easily implemented using these

  14. Fallbacks • Extend the meaning of many syntactical constructions • e.g. fallbacks can be used to implement different kinds of inheritance, a feature not present in Lua

  15. History of Lua • Lua was raised by three people who call themselves collectively as a committee: Roberto Ierusalimschy, , Luiz Henrique de Figueiredo, Waldemar Celes Filho • It was made with modest goals in mind and was finally ‘released’ in 1993

  16. More on Lua’s History • PETROBRAS, a Brazilian petroleum company, needed a program for data entry and asked TeCGraf to do it for them • For this, the ‘committee’ created DEL

  17. Continuing… • After some time, users demanded more features from DEL and at about the same time, the three were working on a configurable report generator for lithology files: SOL

  18. Moving On… • By mid-1993, the authors of DEL and SOL realized that the two programming languages can be combined into one simpler language • And because this language was a development of SOL (sun) they named it Lua (moon in Portugese)

  19. General Characteristics of Lua • Simple • Fast • Portable

  20. Inherited SOL’s syntax Inherited Sol’s concept of being implemented as library Borrowed Modula’s while, if, and repeat until commands Used CLU’s multiple assignments and multiple returns Features of Lua

  21. Adopted C++’s concept of allowing local variable declaration Used ‘..’ instead of the usual ‘+’ for string concatenation Optional semicolons: More Features…

  22. Numbers Strings Associative Tables nil Userdata Functions Lua Languages Six Types

  23. Lua Versions • 1.1 • faster compiler (just-in-time compiler) • New opcodes for contructors • Released in 1994

  24. Lua version 2 • 2.1 • Dropped @ from constructors • Fallbacks were introduced • Allowed user-defined functions • Several kinds of inheritance (including cross-inheritance) • Allowed support for object-oriented programming • Released in 1994

  25. Lua version 2 • 2.4 • Main feature of this release was an external compiler: luac • Pre-complies Lua codes and saves bytecode and string tables to a binary file • Programs can avoid parsing and code generation at run-time, which can be costly • Released in 1996

  26. Lua version 3 • 3.0 • Replaced fallbacks with tag methods • Essentially fallbacks that are selected according to the tag of the operator • Different tables may now have different fallbacks for their operations • A number that represents a new type • Support for conditional compilation • Released in 1997

  27. Lua version 4 • 4.0 • Application Program Interface (API) include explicit states of Lua and is now easier to use and is more efficient • For loop • Released in 2000

  28. LucasArts’ Escape from Monkey Island and Grim Fandango PUC-Rio’s general aperture program(simulate the effects on incident photon stream of physical obstructions) Performance Technologies’ command line interface of CPC4400(a hot swappable ethernet switch) Tollgrade’s DigiTest (telephony network testing) Applications made with Lua

  29. Lua Examples • A very simple configuration file: width = 420 height = width*3/2 -- ensures 3/2 aspect ratio color = "blue"

  30. Another Example • A configuration file using Functions: function Bound (w, h) if w < 20 then w = 20 elseif w > 500 then w = 500 end local minH = w*3/2 -- local variable if h < minH then h = minH end return w, h end width, height = Bound(420, 500) if monochrome then color = "black" else color = "blue" end

  31. A Question that need to be Answered How does Lua apply the new configurations to the original program / application?

  32. The Answer… • Lua at runtime, calls out the C and C++ functions of the original programming language used and uses those functions to apply the new configurations

  33. For More Information… • http://www.lua.org

  34. The End At last… ;)

More Related