Node.js rethought for Lua.

Emilua is a cross-platform runtime for LuaJIT programs. It gives you networking, files, timers, processes, and concurrent execution in one place—roughly the role Node.js plays for JavaScript.

The similarity is about the job, not the API. Emilua replaces callback- and promise-shaped concurrency with fibers, gives you control over how independent Lua VMs use threads, and makes process isolation programmable.

Concurrency without callback-shaped code

Each call to spawn() starts a fiber. When one fiber waits, another can run. This deliberately small program uses timers to make that behavior visible:

local sleep = require("time").sleep

local numbers = {8, 42, 38, 111, 2, 39, 1}

for _, n in pairs(numbers) do
    spawn(function()
        sleep(n / 100)
        print(n)
    end)
end

Save it as sleepsort.lua and run emilua sleepsort.lua. The numbers arrive in ascending order. Sleepsort is a demonstration, not a recommended sorting algorithm.

Fibers, not promise plumbing

Node.js has callbacks, promises, and async/await. Emilua takes a different bet: waiting should be part of the runtime’s concurrency model, not a convention every library must reinvent.

An initiating I/O function suspends the current fiber while other ready work runs. Your function keeps ordinary Lua control flow. Cancellation, cleanup handlers, mutexes, and condition variables are part of the same model.

Back-pressure remains your policy

Emilua exposes small, composable read and write operations rather than hiding an implicit write buffer behind them. Choose the queueing, batching, and cancellation policies that fit your protocol.

TCP, UDP, TLS, DNS, files, pipes, serial ports, clocks, timers, and filesystem operations are available through portable interfaces. The runtime uses native operating-system facilities through Boost.Asio.

One VM or many

Fibers share a Lua VM. When you need isolation or parallelism, spawn independent Lua VMs as actors and communicate through message passing. Then decide how execution contexts map to threads.

A single runtime does not have to mean a single global threading policy. A thread can be dedicated to one VM or shared among several VMs, and different thread pools can coexist.

Isolation you can program

Run risky parsing or plugin work in a separate process and hand it only the resources you choose. A sandbox starts with an inbox; the supervisor decides what else it receives.

Emilua exposes Linux namespaces, seccomp, and Landlock, plus FreeBSD jails and Capsicum. The same actor machinery can drive compartmentalized applications and custom container setup. Explore sandboxing.

Know what you are getting

Emilua targets Windows, Linux, and FreeBSD, subject to LuaJIT architecture support. Portable I/O does not make OS-specific sandboxing APIs identical on every system.

It is not a Node.js compatibility layer, a web framework, or just a container tool. HTTP, WebSocket, Qt Quick, and other integrations live in separate plugins. If a fixed command-line container configuration already does everything you need, a dedicated tool may be simpler; Emilua’s advantage is programmable control.