0% found this document useful (0 votes)
5 views24 pages

Presentation 3

Lua is a lightweight scripting language used in various applications, especially in gaming and embedded systems, with notable uses in World of Warcraft, Angry Birds, and Roblox. Developed at PUC-Rio, Lua evolved from earlier languages Sol and DEL, focusing on ease of use and portability. Its versatility and support for multiple programming paradigms make it a popular choice for developers, with ongoing improvements ensuring its relevance in the future.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views24 pages

Presentation 3

Lua is a lightweight scripting language used in various applications, especially in gaming and embedded systems, with notable uses in World of Warcraft, Angry Birds, and Roblox. Developed at PUC-Rio, Lua evolved from earlier languages Sol and DEL, focusing on ease of use and portability. Its versatility and support for multiple programming paradigms make it a popular choice for developers, with ongoing improvements ensuring its relevance in the future.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Lua

By Aastha Malhotra and Diljan Shah


What is Lua?
• Lua is a powerful but lightweight
scripting language that supports
procedural, object-oriented,
functional and data driven
programming.
• Lua is used in many industrial
applications focused mainly on
embedded systems and games.
• The most recognized uses of Lua
include World of warcraft, Angry
Birds and Roblox.
• Lua is designed, implemented, and
maintained by a team in PUC-Rio,
the Pontifical Catholic University of
Rio de Janerio in Brazil
Who created • It was born in Tecgraf, which was

Lua? formerly the Computer Graphics


Technology Group of PUC-Rio
• But now housed at LabLua, which is
a laboratory of the Department of
Computer Science of PUC-Rio
• Lua was inherited from a
specialized description

Why was
language called Sol
• Sol was being used to
configure an application
called PGM, which was a

Lua
configurable report generator
for lithology profiles
• Later, the team decided that Sol
and DEL could be combined into

Created?
a single, more powerful language
• They decided they wanted a real
programming language that had
assignment, control structures,
subroutines, etc.
It has two origins:
• Lua came from a language called Sol, which was used to

Lua Creation set up an application named PGM. PGM was a tool for
creating reports on rock layers for Petrobras, a big oil
company. Another language called DEL was used

Continued alongside Sol for entering data.


• Finally, they wanted the language to not have
any cryptic syntax/semantics and should be highly
portable
• This new language was a modified version of Sol
and since Sol meant sun in Portuguese, someone
suggest Lua, which meant moon in Portuguese
• Lua inherited the syntax for record and list
constructions from Sol, but unified the
implementation using associative tables: records use
strings as indices and lists use integers
• Besides these data description facilities, Lua had no
other new concepts
Evolution
• Originally being used as an inhouse language for
specific projects, Lua has undergone many
improvements and bloomed into a universal
language used in some of the biggest
applications today.
• Lua 5.4 which came out in June 2020 introduced a
garbage collector and additional variable types.
Earlier versions like Lua 5.3 brought in features
such as integers, bitwise operators and the UTF 8
library. Going back to Lua 5.1 from February 2006
it had improvements like a revamped module
system, incremental garbage collection and
enhanced syntax which solidified Luas
significance in areas like gaming, embedded
systems and scripting. These updates were the
most important ones while also being the most
recent.
Procedural
Programming
function greet(name)
print("Hello, " .. name)
end

• allows developers to write functions and


procedures to encapsulate and reuse code
• Functions in Lua can be defined using the
function keyword and can be nested.
Functional Programming

local square = function(x) return x * x end


print(square(5)) -- Outputs: 25

• first-class citizens, allowing them to be


stored in variables, passed as arguments,
and returned from other functions.
• it supports anonymous functions and
closures
local Person = {}

Object- Person.__index = Person • does not have built-


in support for
Oriented function Person:new(name, age)
local instance = setmetatable({},
classes, but it
provides
Programm Person)
instance.name = name
mechanisms to
implement object-
ing instance.age = age
return instance
oriented concepts
using tables and
end metatables.
• Prototypes and
function Person:greet() inheritance can be
print("Hello, my name is " .. self.name) simulated using
end these constructs.

local john = Person:new("John", 30)


john:greet() -- Outputs: Hello, my name is
John
Data-driven
Programming

• Lua excels in data-driven


programming, which is
particularly useful in game
development and
configuration scripting.
• Data is often represented in
Lua tables, allowing dynamic
and flexible data structures.
Primitive Data Types
Nil: Represents the absence of a value. • local noValue = nil

Boolean: Represents true or false. • local isTrue = true

Number: Represents real (double- • local num = 3.14


precision floating-point) numbers. • local intNum = 42

String: Immutable sequences of • local str = "Hello, Lua"


characters.

Function: Represents executable code


and can be stored in variables, passed • local function add(a, b) return a + b end
as arguments, etc.

Table: The sole native composite data


type in Lua, functioning as arrays, • local tbl = {key1 = "value1", key2 = "value2"}
dictionaries, objects, and more
Interpreted Language
• Interpreter: The Lua interpreter (lua) executes Lua
scripts directly, compiling them to bytecode and
running them on the Lua virtual machine (VM). This
allows for a fast and efficient execution model.
• Compilation: Lua code is compiled into an
intermediate bytecode representation by the Lua
interpreter. This bytecode is then executed by the
Lua VM.
• JIT Compilation: LuaJIT is an alternative
implementation of the Lua interpreter that includes
Just-In-Time (JIT) compilation, significantly improving
performance for computationally intensive tasks.
• Running a Lua script
o lua script.lua
Roblox

• Roblox is the biggest usage case for


Lua, being a gaming hub for creators
around the globe to put their Lua
expertise to the test. You can create
anything and any game you imagine
which is why having created over 40
million games, Roblox has become one
of the biggest active games in history.
World of Warcraft

•World of Warcraft is the second


biggest game that comes from Lua, it
is a massive open world RPG that
came out 20 years ago and had 140
million total players. You create a
character and progress through the
world of Azeroth, gaining items along
the way to become stronger.
Ease of use

• Lua is a beginner friendly language because it has easy to


understand syntax and a welcoming, clear, and consistent
structure. It should be noted that this doesn’t mean its
capabilities are lessened, as Lua supports a wide range of
programming paradigms, including procedural, object-
oriented, and functional programming.

• The best thing about Lua is its versatility and the extent that
it can be used. We can integrate it with other existing
programming languages which makes it an excellent choice
for advancing already existing software.
Hello World Program
Little Program 1 Demonstration
Little Program 2 Demonstration
• Similarities: • Differences:
• All three programming • Lua is considered to be
Comparis languages can support
lighter and easier to
integrate compared to
programming.
on with • Lua and Python share
Python and C++.
• Python is recognized for
other features, like dynamic
typing and being
its easy to use and clear
syntax making it well

languages interpreted languages. suited for development.


• C++ provides
• Both Python and C++ performance
provide a range of capabilities, allows for
libraries that cater to precise control over
application needs. memory at a low level
making it a good choice
for system
programming.

• In turn, all the languages are good in their


own respect and what you are trying to
achieve with it
Similarities with
Other Languages

• Control Structure (Python, Java)


o Supports common control
structures such as 'if', 'while',
and 'for' loops
• Functions (Python, Scheme)
o Can be stored as variables,
passed as arguments, and
returned from other functions
• Dynamic Typing (Python,
Scheme)
o Dynamically typed, types are
determined at runtime
Differences
with Other
Languages
• Table vs. Array/Lists
o Uses tables for almost
everything, including arrays
o Python uses lists and dictionaries
while Java uses arrays and
collections
• Metatables
o Allows developers to change the
behavior of tables (operator
overloading and custom indexing)
o Not directly available in other
languages such as Python or Java
• Global by Default
o All variables in Lua are global by
default unless specified to be
local
Documentation

As Lua is a very popular language used in some of the biggest


applications on the internet, documentation for Lua is very
accessible.

There is an official Lua website: https://www.lua.org/docs.html,


this website provides in depth information about the language,
its history and manual. You can learn the uses for the language
and see its updates throughout the years.

We can additionally find non direct sources such as the Roblox


Creator website so that we can learn how to create games on the
platform.
Growing up, I spent thousands of hours on
Roblox playing games with all types of genres
including Anime Recreations, Horror, Murder
Mystery and Business Owning Simulators.

Future Gaining all this experience led me to see where I


can find flaws in each game and how I can fix
them or improve them. This led me to want to

Project
create my own games for people to play and put
all the ideas I thought of to use.

I realize now though that a one-man team can

Use?
only make it so far, and that you need many
people to create something truly special.

I hope in the future to be a part of a team that


creates a game that players love and enjoy.
Relevancy

• We believe that Lua will continue to grow and become an even more
relevant language in society not only because of its popularity among
various platforms but also because of trends seen in its timeline.
• We see that most of the improvements have happened in recent years and
has exponentially been improved. Even at the start when the language was
first released it was used in world of warcraft which is still one of the biggest
games being released in 2004. This leads me to believe that the years to
come will bring groundbreaking improvements to the language and its
capabilities.
• We predict that though Roblox is one of the biggest platforms in today's
world, in the next 20 years there will be another platform that will be much
bigger even if it’s a completely different application whether it be gaming or
not.
• These reasons lead us to believe that Lua will remain relevant.

You might also like