Programs

This page shows how Coputer programs are written, stored, and executed, and some of the rationale behind the design decisions.

Language

All Coputer programs are written in Luau, a gradually typed scripting language derived from Lua. Luau is maintained and developed by Roblox.

Luau logo
The Luau logo
Luau seal mascot
Hina the Seal, the mascot for Luau

Many options were considered before Luau, including Lua and loads of other scripting languages, a custom bytecode/VM, and WebAssembly. If an existing solution had been chosen, the project would probably be 4-6 months ahead of where it is now. The idea of using Luau was mainly out of love, since it's my favourite programming language and I learned a ton about it by integrating it into Coputer.

Programs are executed entirely within the Execution system, using a custom Luau VM implementation. The custom VM supports almost all of the core language and most of the standard library, with any exclusions being deliberate for determinism or security reasons.

Each program is bundled as source code in a compressed format (files are individually gzipped) and distributed by Communication systems, before finally being stored by Execution systems. The luau-compile tool compiles the entrypoint of the program into Luau bytecode, which is executed by the VM. Any other files required by the entrypoint are loaded and compiled on demand.

Inputs and outputs

Every Coputer program has a type, which defines the shape of its inputs and outputs. The program you're currently viewing is a Web program, meaning it takes HTTP request parameters as input and returns a response as output. The Coputer execution environment provides an args package, allowing programs to access their input parameters. For a web program, this includes the HTTP method, headers, query parameters, and body. The program must also return a value in a specific format depending on its type.

Development

A Communication system can also implement a development mode, allowing for a program to be re-uploaded and re-executed automatically whenever its source code changes.

A development extension for VSCode, providing help to write Coputer programs, is currently a work in progress. It currently provides syntax highlighting and code formatting.