SlideShare a Scribd company logo
1
TERM PAPER
On
Title: Lua
Submitted to
Amity school of Engineering and Technology
AMITY UNIVERSITY UTTAR PRADESH
GAUTAM BUDDHA NAGAR
Guided By - Submitted By –
Guided by: Ms Rashmi Dubey Varun Sharma
Asst. prof. Computer science Dept. 3CS-5x
A2305213337
2013-17
2
DECLARATION
I, Varun Sharma, student of B-TECH (CSE) hereby declare that project titled "Lua" which is
submitted by me to the department of Computer Science and Engineering, Amity school of
Engineering and Technology, Amity University Uttar Pradesh, Noida, in partial fulfillment of
requirement for the award of the degree of Bachelor of Technology in Computer Science and
Engineering, has not been previously formed the basis for the award of any degree, diploma, or other
similar title or recognition
The Author attests that permission has been obtained for the use of any copy righted material
appearing in the Dissertation/Project report other than brief excerpts requiring only proper
acknowledgement in scholarly writing and all such use is acknowledged.
Signature
Noida
Date Varun Sharma
3
CERTIFICATE
This is to certify that Mr. Varun Sharma, student of B-Tech in Computer Science and
Engineering has carried out the work presented in the project entitled “Lua” as a part of first year
program of Bachelor of Technology in Computer Science and Engineering from Amity School of
Engineering and Technology, Amity University, Noida, Uttar Pradesh under my supervision.
Ms. Rashmi Dubey
Amity School of Engineering and Technology
Amity University, Noida, UP
4
Index
1. Preface…………………………………………………………………………..……………………..5
2. Prerequisites…………………………………………………………………..……………………....6
2.1 Programming Paradigms……………………………………………….….…………………….6
2.2 Important Terms……………………………………………………….…….……………………7
3. Introduction………………………………………………………………….…….…………………...8
4. History……………………………………………………………………….…….……………………9
5. Benefits…………………………...………………………………………..……….……………..…..10
6. Evolution…………………………………………...……………………..………….….…………….12
7. Programming in Lua……………………………………..……………...………………….………..14
7.1 Lua VS Other Scripting Languages…………………………..…………..…………..…….....17
8. Discussion & Conclusion……………………………………………...….……………………..…….19
9. References………………………………………………………………...……………..……………..20
5
1. Preface
In this term paper, my main motive will be to know about Lua and how and where it fits in
today’s scenario of software development. Starting with some basic knowledge, I will begin with the
History of Lua and then talk about the benefits it provides and then analyze various versions which
have been released and ultimately go towards the programming in Lua. After all that is said and done,
I will compare Lua’s execution timings with that of other scripting languages.
Throughout this term paper, my objective have been to gather as much as relevant
knowledge as possible and produce it in a concise yet informative matter. Excluding all the
unnecessary information and focusing on that main idea behind the language and what ways it can be
used.
6
2. Prerequisites
2.1 Programming Paradigms
A programming paradigm is the basic style of programing for computers, a procedure of building
various elements and structures in a computer program. Even though there are numerous types of
programing paradigms available, we would only restrict ourselves to those used in Lua.
 Scripting Languages
A Language which supports scripts, which are actually interpreted by an interpreter rather
than compiled and automate the execution of various tasks which could be executed by a
human operator one by one are called scripting languages [1]. They are also called
extension languages as they can provide extensions to already built programs (Such as
Add-ons for web browsers). They also sometimes referred to as very high-level
languages as they have a very high level of abstraction.
As stated earlier, they are interpreted and not compiled, which makes it easier for
programmers to de-bug the program or add new features without any need of re-building
the entire software. And since, Lua is dynamic in nature, programs written in it can be
dynamically altered during runtime.
 Functional Programming
It is a programing paradigm which views programs with a mathematical approach and
avoids mutable data. It emphasizes more on functions which gives out same results for
same inputs, i.e. – the output does not matter upon the program state but the values input
so that if same value in entered twice at different points of time, same result is obtained.
 Procedural, prototype-based Object Oriented
Lua is a Procedural, prototype-based Object Oriented language, which particularly means
– OOP concepts (Like - classes, etc.) are not ‘actually’ embedded within the language but
can be faked through ‘tables’. Procedural means the language tells the computer the step
by step process of what to do and when to do it, prototype-based means that inheritance
is achieved by cloning or duplicating the existing objects and use them as ‘prototypes’ [2]
[3].
7
2.2 Important Terms
 Interpreted Language
A programming language which is not pre-compiled using a compiler but is interpreted during
runtime by an interpreter which translates each of the given statement in a program into one
or more predefined procedures or subroutines which already are compiled into the machine is
known as an interpreted language [4]. Lua is one good example of it.
 Subroutine
A subroutine is a succession of instructions to a program that performs a certain task which is
packaged as a single entity/unit [5].
 Dynamically Typed Language
This simply means that the variables in the language does not have any ‘data types’, only the
values associated with them do and language does not have any type definitions.
 Multi-Paradigm Programming Language
A programming language is called “Multi-Paradigm” if it supports more than one paradigms
for programming.
 Prototype-Based Programming
It is a style of OOP in which inheritance is achieved through duplication of the objects which
then serves as prototype.
8
3. Introduction
Lua is a scripting language designed by a small team of three developers - Roberto
Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo; at Pontifical Catholic University
(Situated in Rio de Janeiro) in 1993. It is known to be extremely lightweight (with Lua interpreter being
only about 182KB in size!), fast with less overhead, easily embeddable and powerful. Since it is
written in ANSI C, it is extensively cross-platform and able to run on virtually anything.
It have achieved an honorable place in the Gaming as well as other Industries and has been
used in various famous Softwares and Games, such as Angry Birds, Word of Warcraft, Baldur's Gate,
Apache HTTP server, Firefox Web Browser and many more! The main reason being, it can be easily
used to extend the capabilities of an existing program without any need of re-building the software. In
gaming industry, it is mainly used for scripting the AI logic. Another advantage of Lua is that - it is a
free open-source software, which is distributed under the MIT license, allowing it to be used for
virtually any purpose (commercial or non-commercial) at no cost at all!
The name Lua (Not “LUA”) is a Portuguese word meaning moon [6]. The latest version being 5.2, Lua
have had various additions to its features and implementations. However, being an open source
language, users are free to pursue using any version they wish to use for as long as they like.
9
4. History
Lua was created in 1993 by a team of 3 developers from the team TecGraf, Roberto,
Waldemar Celes and Luiz Henrique at Pontific Catholic University situated in Rio de Janeiro city of
Brazil. Brazil had a really strict trade policy known as market reserve from 1977 until 1992 for
computer software and hardware. So in that scenario, it was a matter of affordability for TechGraf’s
clients which prevented from being able to buy custom-made softwares from other part of the world.
And all this lead TechGraf to build the basic tools it required from the beginning [7].
Lua’s predecessors which can also be considered its “father and mother” where the
TechGraf’s data-configuration/description languages - data-entry language (DEL) and SOL (Simple
Object Language). Both of these languages were developed independently by TechGraf during 1992-
1993 to attain additional freedom in two individual projects which they were doing for Petrobras.
Since, there was absence of flow-control structures in both DEL as well as SOL and Petrobras felt
need for addition of more programming power to their programs.
In 1993, Tcl was the only real contender as it was designed to be embedded into applications
but it had a very queer syntax, there was not much support in terms of data-description and moreover,
it ran exclusively on Unix platform. And since their clients had a diverse range of computer platforms,
it was more logical for them to create their own scripting language keeping the diversity of computer
platforms in mind and maintaining a simple syntax as their clients where not professional
programmers. As they expected their future products to also have a need to embed a scripting
language and it went with their do-it-yourself approach which they had back then, they went on to
create their own scripting language to fulfill their need for more programming power and simple syntax
for the potential users. They went on and used ANSI C to make it cross-platform and created Lua, a
successor for DEL and SOL (Which means Sun in Portuguese, so you know where Lua/Moon came
from).
10
5. Benefits
 It’s popular
Many industrial languages have used Lua to achieve better user experience and increase
functionality via plugins (One such example being - Adobe's Photoshop Lightroom), with
extensive focus on embedded systems (Such as the Ginga middleware, designed for digital
TV in Brazil) as well as games (Including Angry Birds, Civilization V and World of Warcraft).
As of today, Lua is the most used language in games, having multiple game Engines using it.
There have been several books published about Lua and it have a simple and detailed
manual written by its developers.
 Lua is fast
When it comes to performance, Lua is amongst fastest scripting languages. Quite a lot of
tests and comparisons of execution time of Lua with other scripting languages reveal Lua as
the fastest language in the category. It is fast, not only in synthetic benchmarks but in real
world performance too, wide chunks of large applications have been written in Lua.
Additional speed can be achieved with and independent implementation of the language,
namely - LuaJit, which uses just-in-time compiler.
 Lua is cross-platform
Distribution of Lua is in small packages and it is built out of the box on any platform which
comes with ANSI C library. Lua runs on various operating systems such as Windows, UNIX,
mobile platforms such as – Symbian, iOS, BREW, Windows Phone and android with support
with many mobile processors such as ARM and even on IBM mainframes, etc.
 Lua is embeddable
Lua has a very small over-head and can be embedded into any application with ease. It
allows strong integration with other programming languages through its well documented and
easy to use API and its functioning can be easily extended by libraries written in various other
languages as well. Lua has not just been utilized to extend programs coded using C and C++
but also other programming languages such as C#, Ada, Java and also various scripting
languages namely Ruby and Perl.
11
 Lua is powerful (yet simple)
The primary concept behind the design of Lua is to offer meta-mechanisms for
implementation of various features, in place of supplying a cluster of features straight in the
language. For instance, even Lua is not really a pure OOP language, implementation of
classes and inheritance can be done through meta-mechanisms such as tables. The meta-
mechanisms present in Lua bring an economy of concepts as well as keep the language
small and provide all this while permitting extension of semantics in unconventional ways.
 Lua is small
Lua’s tarball (Version 5.2.3) which comprises of both the documentation as well as the source
code, occupies only 246KB of space when compressed and 960KB when Uncompressed. So,
it does not really inflate the size of application in which it is implemented. The original source
code of only of around 20,000 lines of code in C. The Lua interpreter occupies around 182KB
when built along with all the standard libraries and the Lua library occupies around 244KB.
 It’s Free!
Being an open-source software with MIT license, Lua can be used for any purpose, be it
academic or commercial at not costs at all!
12
6. Evolution
Features 1.0 1.1 2.1 2.2 2.4 2.5 3.0 3.1 3.2 4.0 5.0 5.1
Constructors Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Garbage Collection Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Extensible Semantics Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Support for OOP Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Long Strings Yes Yes Yes Yes Yes Yes Yes Yes Yes
Debug API Yes Yes Yes Yes Yes Yes Yes Yes Yes
External Compiler Yes Yes Yes Yes Yes Yes Yes Yes
vararg Function Yes Yes Yes Yes Yes Yes Yes
Pattern Matching Yes Yes Yes Yes Yes Yes Yes
Conditional
Compilation
Yes Yes Yes
Anonymous Functions,
Closures
Yes Yes Yes Yes Yes
Debug Library Yes Yes Yes Yes
Multi-state API Yes Yes Yes
for Statement Yes Yes Yes
Long Comments Yes Yes
Full Lexical Scoping Yes Yes
Booleans Yes Yes
Co-Routines Yes Yes
Incremental Garbage
Collection
Yes
Module System Yes
Since its creation in 1993, Lua have seen various drastic improvements and changes. Version 1.0
was never publically available and the first public release of Lua began with 1.1 which was released
on 1994, 8 July and was free for academic purposes and any commercial use had to be negotiated
but it never was. In Feb 1995, Lua 2.1 came to the scene with support for OOP and this time, it was
freely available for all purposes. Same year, in November, version 2.2 got released with support for
long strings and a couple more features. 2.3 was never released publically and only existed in beta.
And in the next few years, various versions came in with multiple improvements, additions and bug
fixes. On April 2003, Lua 5.0 came with new MIT license having new features such as full lexical
support, Co-Routines for collaborative multi-threading and metatables. The current version of Lua is
5.2, which was released on Dec. 16, 2012 with new key features, such as – finalizers for tables, an
13
emergency garbage collector, a brand new library for bitwise tables, light C functions and goto
statement support. Its latest release is 5.2.3 which was released on Dec. 07, 2013. The work for Lua
5.3 has already been initiated and beta version is available, however no release date is available for
the final version as of 23 June 2014. [8]
14
7. Programming in Lua
Lua is a multi-paradigm language. It does not really have any classes but it does support the
concept of OOP by ‘faking’ classes through tables and achieving inheritance through prototype-based
programming [9]. Unlike other languages such as C, there is no need to declare any variable.
Variables can be used whenever required and they don’t require any declaration first. Moreover,
variables have no data types, only values do.
There are basically eight types present in Lua – table, userdata, nil, thread, string, Boolean,
function and number.
 Table – The type tables is used for implementation of associative arrays, which means arrays
can be indexed with not just numbers but any type available in Lua apart from Nil and Nan
(Not a Number, it is used for representation of unpresentable results, for example – 0//0).
 Userdata – It is utilized to store any C data into a Lua variable. Its value is actually a pointer
which points to a block of raw memory. Userdata can be further sub-divided into two different
types –
o Full userdata – In it, the management of block memory is performed by Lua.
o Light userdara – The management of memory block is handled by the host.
 Nil – Its main characteristic is to be different from all the values and it signifies the absence of
useful value.
 Thread – Threads are used to implement coroutines, they signify individual threads of
execution. They are different from the threads present in operating systems and Lua also
have support for threads on operating systems which do not have them.
 String – A string is used for representation of immutable sequence of bytes.
 Boolean – It holds value in either true or false.
 Function – Lua support the functionality to call and manipulate functions which have been
written in Lua as well as C.
 Number – it is used for representation of real numbers with double floating point precision.
15
 A simple “Hello world!” program can be as short as one line of code in Lua –
 For swapping two numbers, a temporary variable is required to store the value and then copy
or mathematical addition and subtraction algorithm is required. However, it is built into Lua –
This line of code swaps the value of ‘a’ with that of ‘b’ and the value of ‘b’ with that of ‘a’.
 While loop syntax in Lua –
This program will print ‘Hi’ three times.
print(“Hello world!”)
a,b = b,a
a = 5
while a>2 do
print(“Hi”)
a = a – 1
end
16
 An example of class in Lua –
function Gold_Reserve:new (o)
0 = 0 or
Setmetatable(o, self)
return 0
end
function Gold_Reserve:Deposit (v)
self.Existing = self.Existing + v
end
function Gold_Reserve:Retrieve (v)
if v > self.Existing then error “insufficient gold
available” end
self.Existing = self.Existing – v
end
17
7.1 Lua VS Other Scripting Languages
Lua VS Ruby [10]–
18
Lua VS Python [11]–
So in these benchmarks, it can be seen that Lua is a lot faster than its competing languages.
However, it needs to be noted that it is fast in terms of scripting languages, however if we compare it
with other languages such as C, it will be slower.
19
8. Discussion & Conclusion
Lua is a scripting language which started as a project of a small group for their personal
projects but eventually became famous amongst programmers due to its ease of use, power, speed
of execution of commands, portability as well as small size and little over-head. Lua provides
incredible integration with other leading languages though its API libraries and have become a really
good extension language due to that fact. Many famous programs, games and game engines have
adopted it. It is really useful for game developers as it is a very secretive industry and having Lua in
their game allows modding community to mod the games without even knowing the source code of
the actual game which in turn increases the lifetime of that game, web browsers use Lua for
extensions and plugins, video games use Lua for their AI logic.
Languages like Lua gives people with no programming background an easier way to get
themselves into the field of programming without much investment of time and need of knowing the
actual background processes and provides them with a platform to begin their programming career.
All this, comes along with multiple merits and uses which not many languages are able to seize.
20
9. References
[1] L. Wall, "Programming is Hard, Let's Go Scripting...," 06 12 2007. [Online]. Available:
http://www.perl.com/pub/2007/12/06/soto-11.html. [Accessed 21 05 2014].
[2] j. noble, A. Taivalsaari and I. Moore, Prototype-Based Programming: Concepts, Languages and
Applications, Springer, 1999.
[3] B. C. Pierce, "What is Object-Oriented Programming?," in Types and Programming Languages.,
MIT Press, 2002.
[4] "Interpreted Languages," 06 08 2004. [Online]. Available:
https://earthsci.stanford.edu/computing/unix/programming/interpreted/. [Accessed 03 05
2014].
[5] "Subroutine," [Online]. Available: http://www.computerhope.com/jargon/r/routine.htm.
[Accessed 03 05 2014].
[6] "About, Lua.org," [Online]. Available: http://www.lua.org/about.html#name. [Accessed 06 05
2014].
[7] R. Ierusalimschy, L. H. d. Figueiredo and W. Celes, "Prehistory," in HOPL III Proceedings of the
third ACM SIGPLAN conference on History of programming languages, Rio-d Janeiro, 2007.
[8] "Version History, Lua.Org," [Online]. Available: http://www.lua.org/versions.html. [Accessed 10
06 2014].
[9] K. Jung and A. Brown, Beginning Lua Programming, Wiley Publishing, Inc., 2007.
[10] "Ruby VS Lua," [Online]. Available:
http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&lang=lua&lang2=yarv
&data=u64. [Accessed 15 06 2014].
[11] "Lua VS Phython 3," [Online]. Available:
http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&lang=lua&lang2=pyth
on3&data=u64. [Accessed 15 06 2014].

More Related Content

What's hot (20)

PPTX
Rules for Variable Declaration
uniprint
 
PPTX
Java Tokens
Madishetty Prathibha
 
PDF
Principles of-programming-languages-lecture-notes-
Krishna Sai
 
PPTX
Ruby programming
Kartik Kalpande Patil
 
PPT
1. introduction to html5
JayjZens
 
PPT
Applet life cycle
myrajendra
 
PPTX
C#
Gokul Ram
 
PPT
Visula C# Programming Lecture 1
Abou Bakr Ashraf
 
PPTX
Introduction To C#
rahulsahay19
 
PPT
Web Engineering
Muhammad Muzammal
 
PDF
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
PPSX
Programming Fundamental Presentation
fazli khaliq
 
PPTX
Multithreading in java
Monika Mishra
 
PPTX
Scratch
Shashwat Singh
 
DOC
Black box testing
Nakul Sharma
 
PPTX
Our presentation on algorithm design
Nahid Hasan
 
PPTX
Introduction to java
Saba Ameer
 
PPS
Coding Best Practices
mh_azad
 
PPTX
Algorithm,Pseudocode,Flowchart.pptx
DrThenmozhiKarunanit
 
Rules for Variable Declaration
uniprint
 
Principles of-programming-languages-lecture-notes-
Krishna Sai
 
Ruby programming
Kartik Kalpande Patil
 
1. introduction to html5
JayjZens
 
Applet life cycle
myrajendra
 
Visula C# Programming Lecture 1
Abou Bakr Ashraf
 
Introduction To C#
rahulsahay19
 
Web Engineering
Muhammad Muzammal
 
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
Programming Fundamental Presentation
fazli khaliq
 
Multithreading in java
Monika Mishra
 
Black box testing
Nakul Sharma
 
Our presentation on algorithm design
Nahid Hasan
 
Introduction to java
Saba Ameer
 
Coding Best Practices
mh_azad
 
Algorithm,Pseudocode,Flowchart.pptx
DrThenmozhiKarunanit
 

Viewers also liked (19)

PPT
Prasentation Managed DirectX
A. LE
 
PDF
Introduction to DirectX 11
Krzysztof Marciniak
 
PPTX
Teaching Digital Composition: Tips, Approaches, & Benefits
Amy Goodloe
 
PDF
Article 2015
Siglinde Mtz
 
PPT
Les mis
qhaley
 
PPT
Śniadanie Daje Moc
brandsupportpl
 
PDF
Chapter 09
Tha Mike
 
PPTX
Fencing lifestyle
prosvsports
 
PDF
Series and parallel operation of power devices
Mafaz Ahmed
 
PPT
7 organización de los aprendizajes
Clarita Castrejon
 
PPTX
DC MACHINES
Vikas Kalwani
 
PDF
2 estructura del programa de matematicas 3°
Clarita Castrejon
 
PDF
Image Morphing: A Literature Study
Editor IJCATR
 
PDF
Espais d'eduacicó infantil
escolapratdelariba
 
PPTX
Heathrow Airport - Refurbishment of Terminal 1
Yash Mittal
 
PDF
Direct X
Yash Mittal
 
DOC
Games for language teaching
buket77
 
PPTX
Una. universidad a distancia
margarita_marcano
 
Prasentation Managed DirectX
A. LE
 
Introduction to DirectX 11
Krzysztof Marciniak
 
Teaching Digital Composition: Tips, Approaches, & Benefits
Amy Goodloe
 
Article 2015
Siglinde Mtz
 
Les mis
qhaley
 
Śniadanie Daje Moc
brandsupportpl
 
Chapter 09
Tha Mike
 
Fencing lifestyle
prosvsports
 
Series and parallel operation of power devices
Mafaz Ahmed
 
7 organización de los aprendizajes
Clarita Castrejon
 
DC MACHINES
Vikas Kalwani
 
2 estructura del programa de matematicas 3°
Clarita Castrejon
 
Image Morphing: A Literature Study
Editor IJCATR
 
Espais d'eduacicó infantil
escolapratdelariba
 
Heathrow Airport - Refurbishment of Terminal 1
Yash Mittal
 
Direct X
Yash Mittal
 
Games for language teaching
buket77
 
Una. universidad a distancia
margarita_marcano
 
Ad

Similar to Lua - Programming Language (20)

PDF
Programming in Lua 3rd Edition Roberto Ierusalimschy
akahimernad3
 
PDF
Programming in Lua 3rd Edition Roberto Ierusalimschy
zauriicimc
 
PDF
Where can buy Programming in Lua 2nd Edition Roberto Ierusalimschy ebook with...
maysagolqm
 
PPTX
Use of Lua in Lab Devices
Claus Kühnel
 
PDF
Programming in Lua 2nd Edition Roberto Ierusalimschy
meihuashames
 
PDF
Learn Lua For Ios Game Development 1st Ed Jayant Varma
ijaatdoroci
 
PPTX
1003617297.pptx1003617297.pptx1003617297.pptx
nagalakshmig4
 
PPT
A brief history of Lua - Roberto Ierusalimschy (PUC Rio)
Kore VM
 
PDF
exploring-lua-a-comprehensive-guide-to-the-lightweight-programming-language.pdf
ReynoldSummer
 
PDF
Programming In Lua 3rd Edition Roberto Ierusalimschy
paduchkoxho
 
PDF
Lua زبان برنامه نویسی
Shiraz LUG
 
PDF
Lua tutorial
HarikaReddy115
 
PDF
Buy ebook Amateur Radio Astronomy 7th Edition John Fielding cheap price
maysagolqm
 
PPT
Lua vs python
HoChul Shin
 
PDF
Lua as a business logic language in high load application
Ilya Martynov
 
PDF
The Ring programming language version 1.10 book - Part 6 of 212
Mahmoud Samir Fayed
 
PDF
Lua and its Ecosystem
François Perrad
 
PDF
Lua Programming Beginners Learn Lua Programming Step By Step Very Easy Rizk
janorisavio33
 
PDF
The Ring programming language version 1.9 book - Part 6 of 210
Mahmoud Samir Fayed
 
PPTX
Programming language
MalayKalavadia
 
Programming in Lua 3rd Edition Roberto Ierusalimschy
akahimernad3
 
Programming in Lua 3rd Edition Roberto Ierusalimschy
zauriicimc
 
Where can buy Programming in Lua 2nd Edition Roberto Ierusalimschy ebook with...
maysagolqm
 
Use of Lua in Lab Devices
Claus Kühnel
 
Programming in Lua 2nd Edition Roberto Ierusalimschy
meihuashames
 
Learn Lua For Ios Game Development 1st Ed Jayant Varma
ijaatdoroci
 
1003617297.pptx1003617297.pptx1003617297.pptx
nagalakshmig4
 
A brief history of Lua - Roberto Ierusalimschy (PUC Rio)
Kore VM
 
exploring-lua-a-comprehensive-guide-to-the-lightweight-programming-language.pdf
ReynoldSummer
 
Programming In Lua 3rd Edition Roberto Ierusalimschy
paduchkoxho
 
Lua زبان برنامه نویسی
Shiraz LUG
 
Lua tutorial
HarikaReddy115
 
Buy ebook Amateur Radio Astronomy 7th Edition John Fielding cheap price
maysagolqm
 
Lua vs python
HoChul Shin
 
Lua as a business logic language in high load application
Ilya Martynov
 
The Ring programming language version 1.10 book - Part 6 of 212
Mahmoud Samir Fayed
 
Lua and its Ecosystem
François Perrad
 
Lua Programming Beginners Learn Lua Programming Step By Step Very Easy Rizk
janorisavio33
 
The Ring programming language version 1.9 book - Part 6 of 210
Mahmoud Samir Fayed
 
Programming language
MalayKalavadia
 
Ad

Recently uploaded (20)

PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
PDF
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
PPTX
Introduction to web development | MERN Stack
JosephLiyon
 
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
PPTX
declaration of Variables and constants.pptx
meemee7378
 
PDF
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
PPTX
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
PDF
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
PDF
Rewards and Recognition (2).pdf
ethan Talor
 
PPTX
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
PPTX
Agentforce – TDX 2025 Hackathon Achievement
GetOnCRM Solutions
 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PDF
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
PDF
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
Introduction to web development | MERN Stack
JosephLiyon
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
declaration of Variables and constants.pptx
meemee7378
 
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
Rewards and Recognition (2).pdf
ethan Talor
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Agentforce – TDX 2025 Hackathon Achievement
GetOnCRM Solutions
 
Automated Test Case Repair Using Language Models
Lionel Briand
 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 

Lua - Programming Language

  • 1. 1 TERM PAPER On Title: Lua Submitted to Amity school of Engineering and Technology AMITY UNIVERSITY UTTAR PRADESH GAUTAM BUDDHA NAGAR Guided By - Submitted By – Guided by: Ms Rashmi Dubey Varun Sharma Asst. prof. Computer science Dept. 3CS-5x A2305213337 2013-17
  • 2. 2 DECLARATION I, Varun Sharma, student of B-TECH (CSE) hereby declare that project titled "Lua" which is submitted by me to the department of Computer Science and Engineering, Amity school of Engineering and Technology, Amity University Uttar Pradesh, Noida, in partial fulfillment of requirement for the award of the degree of Bachelor of Technology in Computer Science and Engineering, has not been previously formed the basis for the award of any degree, diploma, or other similar title or recognition The Author attests that permission has been obtained for the use of any copy righted material appearing in the Dissertation/Project report other than brief excerpts requiring only proper acknowledgement in scholarly writing and all such use is acknowledged. Signature Noida Date Varun Sharma
  • 3. 3 CERTIFICATE This is to certify that Mr. Varun Sharma, student of B-Tech in Computer Science and Engineering has carried out the work presented in the project entitled “Lua” as a part of first year program of Bachelor of Technology in Computer Science and Engineering from Amity School of Engineering and Technology, Amity University, Noida, Uttar Pradesh under my supervision. Ms. Rashmi Dubey Amity School of Engineering and Technology Amity University, Noida, UP
  • 4. 4 Index 1. Preface…………………………………………………………………………..……………………..5 2. Prerequisites…………………………………………………………………..……………………....6 2.1 Programming Paradigms……………………………………………….….…………………….6 2.2 Important Terms……………………………………………………….…….……………………7 3. Introduction………………………………………………………………….…….…………………...8 4. History……………………………………………………………………….…….……………………9 5. Benefits…………………………...………………………………………..……….……………..…..10 6. Evolution…………………………………………...……………………..………….….…………….12 7. Programming in Lua……………………………………..……………...………………….………..14 7.1 Lua VS Other Scripting Languages…………………………..…………..…………..…….....17 8. Discussion & Conclusion……………………………………………...….……………………..…….19 9. References………………………………………………………………...……………..……………..20
  • 5. 5 1. Preface In this term paper, my main motive will be to know about Lua and how and where it fits in today’s scenario of software development. Starting with some basic knowledge, I will begin with the History of Lua and then talk about the benefits it provides and then analyze various versions which have been released and ultimately go towards the programming in Lua. After all that is said and done, I will compare Lua’s execution timings with that of other scripting languages. Throughout this term paper, my objective have been to gather as much as relevant knowledge as possible and produce it in a concise yet informative matter. Excluding all the unnecessary information and focusing on that main idea behind the language and what ways it can be used.
  • 6. 6 2. Prerequisites 2.1 Programming Paradigms A programming paradigm is the basic style of programing for computers, a procedure of building various elements and structures in a computer program. Even though there are numerous types of programing paradigms available, we would only restrict ourselves to those used in Lua.  Scripting Languages A Language which supports scripts, which are actually interpreted by an interpreter rather than compiled and automate the execution of various tasks which could be executed by a human operator one by one are called scripting languages [1]. They are also called extension languages as they can provide extensions to already built programs (Such as Add-ons for web browsers). They also sometimes referred to as very high-level languages as they have a very high level of abstraction. As stated earlier, they are interpreted and not compiled, which makes it easier for programmers to de-bug the program or add new features without any need of re-building the entire software. And since, Lua is dynamic in nature, programs written in it can be dynamically altered during runtime.  Functional Programming It is a programing paradigm which views programs with a mathematical approach and avoids mutable data. It emphasizes more on functions which gives out same results for same inputs, i.e. – the output does not matter upon the program state but the values input so that if same value in entered twice at different points of time, same result is obtained.  Procedural, prototype-based Object Oriented Lua is a Procedural, prototype-based Object Oriented language, which particularly means – OOP concepts (Like - classes, etc.) are not ‘actually’ embedded within the language but can be faked through ‘tables’. Procedural means the language tells the computer the step by step process of what to do and when to do it, prototype-based means that inheritance is achieved by cloning or duplicating the existing objects and use them as ‘prototypes’ [2] [3].
  • 7. 7 2.2 Important Terms  Interpreted Language A programming language which is not pre-compiled using a compiler but is interpreted during runtime by an interpreter which translates each of the given statement in a program into one or more predefined procedures or subroutines which already are compiled into the machine is known as an interpreted language [4]. Lua is one good example of it.  Subroutine A subroutine is a succession of instructions to a program that performs a certain task which is packaged as a single entity/unit [5].  Dynamically Typed Language This simply means that the variables in the language does not have any ‘data types’, only the values associated with them do and language does not have any type definitions.  Multi-Paradigm Programming Language A programming language is called “Multi-Paradigm” if it supports more than one paradigms for programming.  Prototype-Based Programming It is a style of OOP in which inheritance is achieved through duplication of the objects which then serves as prototype.
  • 8. 8 3. Introduction Lua is a scripting language designed by a small team of three developers - Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo; at Pontifical Catholic University (Situated in Rio de Janeiro) in 1993. It is known to be extremely lightweight (with Lua interpreter being only about 182KB in size!), fast with less overhead, easily embeddable and powerful. Since it is written in ANSI C, it is extensively cross-platform and able to run on virtually anything. It have achieved an honorable place in the Gaming as well as other Industries and has been used in various famous Softwares and Games, such as Angry Birds, Word of Warcraft, Baldur's Gate, Apache HTTP server, Firefox Web Browser and many more! The main reason being, it can be easily used to extend the capabilities of an existing program without any need of re-building the software. In gaming industry, it is mainly used for scripting the AI logic. Another advantage of Lua is that - it is a free open-source software, which is distributed under the MIT license, allowing it to be used for virtually any purpose (commercial or non-commercial) at no cost at all! The name Lua (Not “LUA”) is a Portuguese word meaning moon [6]. The latest version being 5.2, Lua have had various additions to its features and implementations. However, being an open source language, users are free to pursue using any version they wish to use for as long as they like.
  • 9. 9 4. History Lua was created in 1993 by a team of 3 developers from the team TecGraf, Roberto, Waldemar Celes and Luiz Henrique at Pontific Catholic University situated in Rio de Janeiro city of Brazil. Brazil had a really strict trade policy known as market reserve from 1977 until 1992 for computer software and hardware. So in that scenario, it was a matter of affordability for TechGraf’s clients which prevented from being able to buy custom-made softwares from other part of the world. And all this lead TechGraf to build the basic tools it required from the beginning [7]. Lua’s predecessors which can also be considered its “father and mother” where the TechGraf’s data-configuration/description languages - data-entry language (DEL) and SOL (Simple Object Language). Both of these languages were developed independently by TechGraf during 1992- 1993 to attain additional freedom in two individual projects which they were doing for Petrobras. Since, there was absence of flow-control structures in both DEL as well as SOL and Petrobras felt need for addition of more programming power to their programs. In 1993, Tcl was the only real contender as it was designed to be embedded into applications but it had a very queer syntax, there was not much support in terms of data-description and moreover, it ran exclusively on Unix platform. And since their clients had a diverse range of computer platforms, it was more logical for them to create their own scripting language keeping the diversity of computer platforms in mind and maintaining a simple syntax as their clients where not professional programmers. As they expected their future products to also have a need to embed a scripting language and it went with their do-it-yourself approach which they had back then, they went on to create their own scripting language to fulfill their need for more programming power and simple syntax for the potential users. They went on and used ANSI C to make it cross-platform and created Lua, a successor for DEL and SOL (Which means Sun in Portuguese, so you know where Lua/Moon came from).
  • 10. 10 5. Benefits  It’s popular Many industrial languages have used Lua to achieve better user experience and increase functionality via plugins (One such example being - Adobe's Photoshop Lightroom), with extensive focus on embedded systems (Such as the Ginga middleware, designed for digital TV in Brazil) as well as games (Including Angry Birds, Civilization V and World of Warcraft). As of today, Lua is the most used language in games, having multiple game Engines using it. There have been several books published about Lua and it have a simple and detailed manual written by its developers.  Lua is fast When it comes to performance, Lua is amongst fastest scripting languages. Quite a lot of tests and comparisons of execution time of Lua with other scripting languages reveal Lua as the fastest language in the category. It is fast, not only in synthetic benchmarks but in real world performance too, wide chunks of large applications have been written in Lua. Additional speed can be achieved with and independent implementation of the language, namely - LuaJit, which uses just-in-time compiler.  Lua is cross-platform Distribution of Lua is in small packages and it is built out of the box on any platform which comes with ANSI C library. Lua runs on various operating systems such as Windows, UNIX, mobile platforms such as – Symbian, iOS, BREW, Windows Phone and android with support with many mobile processors such as ARM and even on IBM mainframes, etc.  Lua is embeddable Lua has a very small over-head and can be embedded into any application with ease. It allows strong integration with other programming languages through its well documented and easy to use API and its functioning can be easily extended by libraries written in various other languages as well. Lua has not just been utilized to extend programs coded using C and C++ but also other programming languages such as C#, Ada, Java and also various scripting languages namely Ruby and Perl.
  • 11. 11  Lua is powerful (yet simple) The primary concept behind the design of Lua is to offer meta-mechanisms for implementation of various features, in place of supplying a cluster of features straight in the language. For instance, even Lua is not really a pure OOP language, implementation of classes and inheritance can be done through meta-mechanisms such as tables. The meta- mechanisms present in Lua bring an economy of concepts as well as keep the language small and provide all this while permitting extension of semantics in unconventional ways.  Lua is small Lua’s tarball (Version 5.2.3) which comprises of both the documentation as well as the source code, occupies only 246KB of space when compressed and 960KB when Uncompressed. So, it does not really inflate the size of application in which it is implemented. The original source code of only of around 20,000 lines of code in C. The Lua interpreter occupies around 182KB when built along with all the standard libraries and the Lua library occupies around 244KB.  It’s Free! Being an open-source software with MIT license, Lua can be used for any purpose, be it academic or commercial at not costs at all!
  • 12. 12 6. Evolution Features 1.0 1.1 2.1 2.2 2.4 2.5 3.0 3.1 3.2 4.0 5.0 5.1 Constructors Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Garbage Collection Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Extensible Semantics Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Support for OOP Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Long Strings Yes Yes Yes Yes Yes Yes Yes Yes Yes Debug API Yes Yes Yes Yes Yes Yes Yes Yes Yes External Compiler Yes Yes Yes Yes Yes Yes Yes Yes vararg Function Yes Yes Yes Yes Yes Yes Yes Pattern Matching Yes Yes Yes Yes Yes Yes Yes Conditional Compilation Yes Yes Yes Anonymous Functions, Closures Yes Yes Yes Yes Yes Debug Library Yes Yes Yes Yes Multi-state API Yes Yes Yes for Statement Yes Yes Yes Long Comments Yes Yes Full Lexical Scoping Yes Yes Booleans Yes Yes Co-Routines Yes Yes Incremental Garbage Collection Yes Module System Yes Since its creation in 1993, Lua have seen various drastic improvements and changes. Version 1.0 was never publically available and the first public release of Lua began with 1.1 which was released on 1994, 8 July and was free for academic purposes and any commercial use had to be negotiated but it never was. In Feb 1995, Lua 2.1 came to the scene with support for OOP and this time, it was freely available for all purposes. Same year, in November, version 2.2 got released with support for long strings and a couple more features. 2.3 was never released publically and only existed in beta. And in the next few years, various versions came in with multiple improvements, additions and bug fixes. On April 2003, Lua 5.0 came with new MIT license having new features such as full lexical support, Co-Routines for collaborative multi-threading and metatables. The current version of Lua is 5.2, which was released on Dec. 16, 2012 with new key features, such as – finalizers for tables, an
  • 13. 13 emergency garbage collector, a brand new library for bitwise tables, light C functions and goto statement support. Its latest release is 5.2.3 which was released on Dec. 07, 2013. The work for Lua 5.3 has already been initiated and beta version is available, however no release date is available for the final version as of 23 June 2014. [8]
  • 14. 14 7. Programming in Lua Lua is a multi-paradigm language. It does not really have any classes but it does support the concept of OOP by ‘faking’ classes through tables and achieving inheritance through prototype-based programming [9]. Unlike other languages such as C, there is no need to declare any variable. Variables can be used whenever required and they don’t require any declaration first. Moreover, variables have no data types, only values do. There are basically eight types present in Lua – table, userdata, nil, thread, string, Boolean, function and number.  Table – The type tables is used for implementation of associative arrays, which means arrays can be indexed with not just numbers but any type available in Lua apart from Nil and Nan (Not a Number, it is used for representation of unpresentable results, for example – 0//0).  Userdata – It is utilized to store any C data into a Lua variable. Its value is actually a pointer which points to a block of raw memory. Userdata can be further sub-divided into two different types – o Full userdata – In it, the management of block memory is performed by Lua. o Light userdara – The management of memory block is handled by the host.  Nil – Its main characteristic is to be different from all the values and it signifies the absence of useful value.  Thread – Threads are used to implement coroutines, they signify individual threads of execution. They are different from the threads present in operating systems and Lua also have support for threads on operating systems which do not have them.  String – A string is used for representation of immutable sequence of bytes.  Boolean – It holds value in either true or false.  Function – Lua support the functionality to call and manipulate functions which have been written in Lua as well as C.  Number – it is used for representation of real numbers with double floating point precision.
  • 15. 15  A simple “Hello world!” program can be as short as one line of code in Lua –  For swapping two numbers, a temporary variable is required to store the value and then copy or mathematical addition and subtraction algorithm is required. However, it is built into Lua – This line of code swaps the value of ‘a’ with that of ‘b’ and the value of ‘b’ with that of ‘a’.  While loop syntax in Lua – This program will print ‘Hi’ three times. print(“Hello world!”) a,b = b,a a = 5 while a>2 do print(“Hi”) a = a – 1 end
  • 16. 16  An example of class in Lua – function Gold_Reserve:new (o) 0 = 0 or Setmetatable(o, self) return 0 end function Gold_Reserve:Deposit (v) self.Existing = self.Existing + v end function Gold_Reserve:Retrieve (v) if v > self.Existing then error “insufficient gold available” end self.Existing = self.Existing – v end
  • 17. 17 7.1 Lua VS Other Scripting Languages Lua VS Ruby [10]–
  • 18. 18 Lua VS Python [11]– So in these benchmarks, it can be seen that Lua is a lot faster than its competing languages. However, it needs to be noted that it is fast in terms of scripting languages, however if we compare it with other languages such as C, it will be slower.
  • 19. 19 8. Discussion & Conclusion Lua is a scripting language which started as a project of a small group for their personal projects but eventually became famous amongst programmers due to its ease of use, power, speed of execution of commands, portability as well as small size and little over-head. Lua provides incredible integration with other leading languages though its API libraries and have become a really good extension language due to that fact. Many famous programs, games and game engines have adopted it. It is really useful for game developers as it is a very secretive industry and having Lua in their game allows modding community to mod the games without even knowing the source code of the actual game which in turn increases the lifetime of that game, web browsers use Lua for extensions and plugins, video games use Lua for their AI logic. Languages like Lua gives people with no programming background an easier way to get themselves into the field of programming without much investment of time and need of knowing the actual background processes and provides them with a platform to begin their programming career. All this, comes along with multiple merits and uses which not many languages are able to seize.
  • 20. 20 9. References [1] L. Wall, "Programming is Hard, Let's Go Scripting...," 06 12 2007. [Online]. Available: http://www.perl.com/pub/2007/12/06/soto-11.html. [Accessed 21 05 2014]. [2] j. noble, A. Taivalsaari and I. Moore, Prototype-Based Programming: Concepts, Languages and Applications, Springer, 1999. [3] B. C. Pierce, "What is Object-Oriented Programming?," in Types and Programming Languages., MIT Press, 2002. [4] "Interpreted Languages," 06 08 2004. [Online]. Available: https://earthsci.stanford.edu/computing/unix/programming/interpreted/. [Accessed 03 05 2014]. [5] "Subroutine," [Online]. Available: http://www.computerhope.com/jargon/r/routine.htm. [Accessed 03 05 2014]. [6] "About, Lua.org," [Online]. Available: http://www.lua.org/about.html#name. [Accessed 06 05 2014]. [7] R. Ierusalimschy, L. H. d. Figueiredo and W. Celes, "Prehistory," in HOPL III Proceedings of the third ACM SIGPLAN conference on History of programming languages, Rio-d Janeiro, 2007. [8] "Version History, Lua.Org," [Online]. Available: http://www.lua.org/versions.html. [Accessed 10 06 2014]. [9] K. Jung and A. Brown, Beginning Lua Programming, Wiley Publishing, Inc., 2007. [10] "Ruby VS Lua," [Online]. Available: http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&lang=lua&lang2=yarv &data=u64. [Accessed 15 06 2014]. [11] "Lua VS Phython 3," [Online]. Available: http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&lang=lua&lang2=pyth on3&data=u64. [Accessed 15 06 2014].