Menu
Coddy logo textTech

Why Use Luau?

Part of the Introduction To Luau section of Coddy's Lua journey — lesson 2 of 73.

Luau's type system offers three major benefits that make development safer and more efficient.

Catch errors early: the type checker analyzes your code while you edit, before it runs. Consider a classic Lua bug — passing nil where a number is expected:

-- Lua: nothing warns you about this
local function calculateTotal(price, tax)
    return price + tax
end

print(calculateTotal(nil, 0.1))
-- ✗ runtime error: attempt to perform arithmetic on nil

In plain Lua that crash only happens when the bad call finally executes — maybe in front of your users. Worse, Lua sometimes hides the bug entirely: "50" + 0.1 silently coerces the string and returns 50.1… until the day the string isn't numeric. With Luau annotations the mistake is flagged immediately:

local function calculateTotal(price: number, tax: number): number
    return price + tax
end

calculateTotal(nil, 0.1) -- ✗ type error while editing: nil is not a number

Better code readability: annotations serve as documentation. price: number tells you and your teammates exactly what a function expects and returns — no guessing, no digging through the implementation.

Enhanced development tools: because the editor knows each variable's type, you get accurate autocompletion, safer refactors, and smarter navigation. Type a dot after a typed value and the editor lists exactly what's available.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction To Luau