
Discover Lua as a dynamically typed, interpreted scripting language that blends procedural, object-oriented, and data-driven programming. Learn basic constructs, tables, closures, modules, and C interop for rapid prototyping.
Learn why Lua derives from Portuguese word for moon and how this lightweight embedded scripting language supports procedural, object-oriented, functional, and data-driven programming with dynamic typing and incremental garbage collection.
Lua is a proven, robust scripting language known for speed, portability, and embeddability, used in Lightroom and games, with a permissive open-source license and meta programming features.
Visit the Lua website to get started, explore the demo site, and run a hello world example. Download and install a Lua IDE, then follow the tour and begin coding.
Begin with a hello world program in Lua using an ide; print a string, omit the semicolon, add a single line comment, and run multiple statements to demonstrate hello world.
This lecture explains Lua chunks as sequences of commands or statements and demonstrates running code via interactive mode or dofile, including Hello World, assignments, and multi-line function definitions.
Explore Lua lexical conventions: valid identifiers use letters, digits, and underscores, start with a letter, not with two digits, and are case sensitive. Learn about reserved words and semicolon usage.
Learn Lua comments, including single-line comments that start with two dashes and multi-line blocks using brackets, and apply tricks to enable or ignore code efficiently.
Explore global variables and their behavior in Lua: they can be used before declaration, and uninitialized ones print nil. Assigning nil reverts them to undeclared status, with memory reclaimed.
Explore Lua's dynamically typed nature, with no type definitions, where a value carries its type and a variable can hold nil or types, including boolean, string, userdata, function, and table.
Learn how the nil type in Lua represents the absence of a value, how uninitialized globals default to nil, and how nil participates in conditional expressions.
Learn Lua booleans and truthiness, where only false and nil are false, while other values including empty strings are truthy, and the and, or, not operators use short-circuit evaluation.
Explore how Lua handles numerals, including integer and double precision representations, decimal and exponent forms, hexadecimal constants, and type checks for integers versus floats.
Explore arithmetic and relational operators in Lua, including subtraction, multiplication, division, negation, and integer division; understand automatic type handling, float vs integer results, and type-sensitive comparisons.
Explore the Lua math library by performing trigonometric calculations in radians, converting degrees to radians, generating random numbers, and applying logarithms, rounding, and integer wrapping with max and min.
Explore how Lua strings are immutable and concatenation creates new strings. Note that length returns bytes, not characters in UTF-8, and convert numbers to strings before concatenation.
Learn to write long strings in Lua by delimiting with matching square brackets, spanning multiple lines, ignoring the first newline, and using equals signs to customize the delimiter when needed.
Explore how Lua coerces numbers and strings, showing implicit conversions during concatenation and explicit casts with tostring and tonumber, including base 2–36 and nil on invalid input.
Explore Lua's string library functions, including length, bytes, reverse, upper, lower, sub, cat, and format, plus find, gsub, and char; learn indexing from 1 and negative indices and string immutability.
Lua tables serve as the language's primary data structuring mechanism, using key-value pairs as associative arrays; create tables with constructors, assign keys, and observe reference behavior and garbage collection.
Learn how Lua tables index values with numeric and string keys, how global variables are stored in a table, and how string keys may convert to numbers.
Explore how lua uses table constructors to create and initialize objects, including list, key-value, and mixed styles, with indices starting at 1, nested tables, and negative index limitations.
Explore how Lua uses tables to represent lists and sequences, with 1-based indices, length checks, and handling holes and nil values for reliable list operations.
Explore three Lua table traversal methods: using pairs, using ipairs for list-like tables, and observing how numeric keys preserve order while non-numeric keys yield undefined order.
Explore Lua's table library for lists and sequences, learning table.insert, table.remove, and table.move to insert, remove, or move elements and build stacks, queues, and double-ended queues.
Learn how to define and call Lua functions, pass varying arguments, handle defaults and nil, and return values, with examples of print and C interop.
Learn how Lua returns multiple values, use pattern matching with string.find, and write functions that return both values and indices, including the max value and its index.
This lecture explores Lua variadic functions, showing how a function can accept a variable number of arguments using the ... syntax, collect them, and compute sums while handling extra parameters.
Lua's table.unpack function returns multiple values from a list, with optional start and end indices; explore examples with print, table.pack, and string.find patterns.
Explore the Lua i/o library, contrasting simple and complete file models, open files, select read, write, or append modes, and perform read and write operations on file handles.
Explore the simple Lua i/o model by reading from the default input or a file handle, writing to the output stream, and using explicit file handles with various read modes.
Compare the simple and complete I/O models in Lua programming, illustrating open, read, write, and seek with explicit file handles, file pointers, and offsets.
Explore Lua control structures, including if, for, while, repeat until, and end terminators, focusing on conditional execution and Lua's truthiness rules.
Explore Lua's if then else control structure and conditional execution, including else if chains and lack of switch statements, with a perform operation example for plus, minus, multiply, and divide.
Explain how the Lua while loop repeats a code block while the condition is true, using do-end syntax, with an example that prints table values and increments an index.
Learn how lua's repeat-until loop executes the body at least once and repeats until the condition becomes true, with local variable scope inside the loop and a practical example.
Learn how the numeric for loop in Lua initializes the control variable, evaluates start and end values, applies an optional step, and demonstrates loop-local scope.
Explore Lua's generic for loop by iterating over tables with key-value pairs using pairs, handling integer and non-integer keys, and using _ to ignore unwanted values.
Break exits the inner loop, not outer blocks, and return ends a function, optionally early or implicitly as the last statement.
Lua treats functions as first class values, assignable to variables and tables, returnable by other functions, supports anonymous functions, and uses proper lexical scoping.
Explore closures and lexical scoping in Lua, showing how inner functions access non-local variables and retain state after their outer function returns, with separate counters demonstrating independent closures.
Master Lua pattern matching using the string library’s find, match, gsub, and gmatch functions. Explore starting positions, plain search, and pattern-based substitutions, plus extracting words with patterns like %w+.
Explore Lua pattern matching, including string patterns, pattern parameters, and escapes; master character classes, magic characters, and repetition for text extraction.
learn to solve the n-queens puzzle with backtracking by placing one queen per row, checking columns and diagonals, and printing all valid configurations.
Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
Topics covered in the course are:
Introduction to Lua
IDE and installation
Basic Language Constructs
Numbers
Strings
Tables
Functions
Input/Output
Blocks and Loops
Closures
Pattern Matching
Date and Time
Bitwise Operations
Data Structures in Lua - Arrays, Matrices, Linked Lists, Queues
Modules and Packages
Iterators and generic for
Metatables and Metamethods
Object Oriented Programming
The Environment
Garbage
Coroutines
C API
So, let's dive into the course