Install

You can install it by using the .msi file here.

Download

Rationale

Lua4Win is a distribution of the Lua programming language for Windows. Lua4Win comes with the Luarocks package manager and is a "batteries-not-included" distribution of Lua. Binary packages are built remotely and are downloaded as needed. The Lua4Win installer contains a copy of LuaJIT, Luarocks, Busybox, and 7zip; which allows it to come in at a slim 2MB. Updates and bugfixes to libraries can be done piecemeal instead of requiring new copies of the whole distribution every time a bug gets fixed.

Usage

After installing, you can launch cmd.exe and run $ lua to get started.

$ lua
LuaJIT 2.0.ROLLING -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 AMD fold cse dce fwd dse narrow loop abc sink fuse
> print("Hello, world!")
Hello, world!
>

You can use CTRL+C to escape the read-evaluate-print-loop. You can also write Lua programs with your favorite text editor and run them with $ lua filename.lua.

note.lua
-- Create a note file with today's date in %APPDATA%
local args = {...} -- extra arguments passed to the program
-- Generate a filename
local note_f = os.getenv("APPDATA")
local today = os.date("%Y-%m-%d")
local note_name = table.concat(args,"-"):gsub("[%W]","-")
local filename = ("%s\note-%s-%s.txt"):format(note_f,today,note_name)
-- Create the file
local fd = assert(io.open(filename,"w"))
assert(fd:close())
-- Open it in notepad
os.execute("notepad.exe " .. filename)
 
$ lua note.lua my first note

Run lua --help for more options for the command line tool, and see the Lua Manual for extensive documentation of the Lua programming language and standard libraries. Also note LuaJIT's extensions

Installing Superpowers

You can use modules that implement more than the standard Lua libraries by running the $ luarocks install >module name< command to download and install modules.

 
$ luarocks install easni
color.lua
local ansi = require("eansi")
ansi.enable = true
local green = ansi.toansi("green")
print(green .. "> implying you need modules")
 
$ lua color.lua

Run $ luarocks --help for more options on the command line tool, and see the Luarocks wiki for more extensive documentation.

Sister languages

Lua4Win makes it easy to download other programming languages that are distributed through the luarocks package manager. Simply luarocks install them like you would any other package.

Moonscript

 
$ luarocks install moonscript
example.moon
class Person
	name: "Alex"
	greet: => print("Hello, " .. @name)

class World extends Person
	name: "World"

with World!
  \greet!
 
$ moon example.moon
Hello, World!

Teal

 
$ luarocks install tl
keys.tl
local function keys<K,V>(xs: {K:V}):{K}
  local ks = {}
  for k, _ in pairs(xs) do
    table.insert(ks, k)
  end
  return ks
end

local s: {integer:string} = keys({ a = 1, b = 2 })
print(table.concat(s))
 
$ tl run keys.tl
ab

Advanced Usage

By default, Lua4Win will install packages in your user directory, at %APPDATA%/luarocks. You can instead choose to install system-wide packages for all users with the --tree system flag, these packages will be located at [INSTALLDIR]/luarocks. You may need to be running as an administrator to install to this location.

Lua4Win's luarocks configuration lives at [INSTALLDIR]/config/config-5.1.lua, and is a regular Lua file you can modify.

All of Lua4Win's binary packages are built using mingw64. If you intend to build your own modules they must be built with mingw64 if you want them to interoperate with Lua4Win-distributed Lua.

Some of Lua4Win's packages needed patching or modification. Source code for these modifications are available at git.lua4.win. Modifications are kept in a seperat *-packaging repo. For example, modifications to busybox-w32 are located in the busybox-w32-packaging repository.