Fireship · @fireship
Lua in 100 Seconds
Uploaded February 14, 2022 · Length 2:24
Summary
Lua language tutorial: fast, lightweight, and easy to learn scripting language for beginners.
- lua language
- scripting language
- programming language
- beginner tutorial
- fast scripting
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
Lua a fast multi-paradigm scripting
- 0:02
language famous for being so underrated
- 0:04
imagine a language that's easier to
- 0:06
learn than python while also being
- 0:08
faster and more portable than python Lua
- 0:10
was named after the moon when it was
- 0:11
designed by a team of computer
- 0:13
scientists in Brazil in 1993 it's
- 0:15
lightweight and extremely fast because
- 0:17
its virtual machine Maps very closely to
- 0:19
see and when used with its Justin Time
- 0:20
compiler it's widely considered the
- 0:22
fastest scripting language in the world
- 0:24
this makes it ideal for embedding into
- 0:26
other applications like World of
- 0:27
Warcraft or Roblox for example where
- 0:30
users can write Lua to build their own
- 0:31
games and features because the language
- 0:33
is embedded into the base game it's easy
- 0:35
to learn because it has only 21 reserved
- 0:37
words and has only one data structuring
- 0:39
mechanism called a table that can
- 0:41
represent arrays dictionaries graphs
- 0:43
trees and more it also supports
- 0:45
collaborative multitasking with co-
- 0:47
routines its standard library is very
- 0:48
minimal but it does have a large
- 0:50
ecosystem of packages with the Lu Rock
- 0:52
package manager to get started install
- 0:54
it then create a file ending in Lua
- 0:57
declare a variable by providing a name
- 0:59
and value by default variables are
- 1:01
Global but make them local with the
- 1:02
local keyword it's a dynamic language so
- 1:04
no type annotations are required we can
- 1:06
then use print to Output the value to
- 1:08
the standard output there are no classes
- 1:10
in Lua but anything you can imagine can
- 1:12
be done with functions and tables a
- 1:14
function is declared with the function
- 1:15
keyword then closed with the nend
- 1:17
keyword functions are first class
- 1:18
objects which means they can be passed
- 1:20
around to other functions to support
- 1:22
functional programming patterns now to
- 1:23
structured data you create tables with
- 1:25
braces a table is actually an associate
- 1:28
of array which means the index in the
- 1:29
the array can be replaced with different
- 1:31
values by default it uses integer values
- 1:34
and the craziest thing about this
- 1:35
language is that it starts the index at
- 1:36
one instead of zero like most languages
- 1:39
that gives us a conventional array but
- 1:40
we can also easily create a dictionary
- 1:42
by giving the keys a string value now we
- 1:44
can use four to Loop over every key
- 1:46
value pair in the table the language is
- 1:48
single threaded but we can use co-
- 1:50
routines to pause and resume a function
- 1:52
create a co- routine then use yield to
- 1:54
suspend its execution now somewhere else
- 1:56
in the code use co-routine resume to
- 1:59
continue execution until you get to the


