Luau for R Developers
Bring R experience to Luau: one-based tables, lexical closures, typed signatures, runtime contracts and metatable objects. Build a stock ledger and port two R reference programs.
R and Luau side by side
The same program in R and in Luau, from the lessons of this course.
Print and Comment
R print uses object-oriented display conventions while cat controls separators and newlines explicitly. Luau print inserts tabs between arguments and a final newline. Build one exact string with .. when needed and return task values to the driver. Luau…
R1cat(paste0("Hi",", Ada"),"\n",sep="")Luau1local name = "Ada"2print(`Hi, {name}`)None and Missing Fields
R lists can contain NULL, and assigning NULL through a list element replacement can remove that element; single-bracket list assignment can preserve a NULL slot. Luau nil removes the table association. Optional annotations do not create stored absence, so use…
R1record <- list(x=NULL); cat("x" %in% names(record),"\n",sep="")Luau1local d = {x = nil}2print(d.x == nil)Ranges to Numeric for
R colon constructs inclusive sequences that can descend automatically; seq_len handles zero-length traversal deliberately. Luau numeric for also includes its bound but requires an explicit negative step for descending iteration. Preserve empty-input behavior…
R1total <- 0; for(i in 1:3) total <- total+i; cat(total,"\n",sep="")Luau1local total = 02for i = 1, 3 do total = total + i end3print(total)Functions and Returns
R arguments are promises evaluated when needed, whereas Luau call arguments are evaluated before the function starts. Luau numeric rebinding stays local and tables permit shared field mutation. Annotations do not validate untrusted input during Run, so check…
R1twice <- function(x) x*2; cat(twice(4),"\n",sep="")Luau1local function twice(x: number): number return x * 2 end2print(twice(4))Lists as Dense Tables
R vectors and lists have value semantics for ordinary modification, with lists allowing heterogeneous elements. Luau dense tables are shared references and table.remove shifts later keys. Assigning nil leaves a hole. Sequence length should not be used to…
R1values <- c("a","b","c"); values <- values[-2]; cat(paste(values,collapse=","),"\n",sep="")Luau1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))Sorting and Comparators
R sort and order return sorted values or positions rather than automatically mutating the caller’s vector. Luau table.sort mutates a dense sequence and expects a Boolean strict-order predicate. Keep the table reference and copy it first when original order…
R1a <- c(3,1,2); b <- sort(a); cat(b[1],"\n",sep="")Luau1local a={3,1,2}2table.sort(a)3print(a[1])
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst Luau Programs
6 lessonsValues and Decisions
5 lessonsIteration and Flow
5 lessonsFunctions and Closures
5 lessonsTables as Collections
5 lessonsOrdering, Modules and Errors
5 lessonsObjects and Owned State
5 lessonsComposition and Object Lookup
6 lessonsProject: Stock Ledger
4 lessonsFinal R Ports
2 lessonsFrequently asked questions
Who is Luau for R Developers for?
For people who already write R and want to learn Luau. Each lesson starts from R you know and shows how Luau does the same thing, so you skip the beginner basics.
Do I need to know Luau already?
No. The course starts with your first Luau program. You need R basics: variables, conditions, loops, functions and collections.
How many lessons does Luau for R Developers have?
Luau for R Developers contains 48 interactive lessons you can complete at your own pace.
What does Luau for R Developers cover?
The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.
Is Luau for R Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.