CLI Reference

The Zym CLI is a single binary that compiles, runs, packages, and inspects Zym programs.

Quick Reference

Command Description
zym Show help information
zym <file.zym> Compile and run source file
zym <file.zbc> Run precompiled bytecode
zym <file.zym> -o <out.zbc> Compile to bytecode
zym <file.zym> -o <out.exe> Compile to standalone executable
zym <file.zbc> -o <out.exe> Pack bytecode into executable
zym <file> -o <out> -r <runtime> Cross-platform packing with explicit runtime
zym <file> --dump Disassemble to console
zym <file> --dump <out.txt> Disassemble to file
zym <file> --strip Strip debug info (smaller output)
zym <file.zym> --preprocess Show preprocessed source
zym <file.zym> --combined Show combined source with modules
zym --version Print version

File Types

Script Arguments

Pass arguments to your script using -- as a delimiter. Everything after -- is forwarded to the script's main(argv) function.

terminal
zym app.zym -- --port 8080 --verbose
app.zym
func main(argv) {
    print(argv);
    // → ["zym", "--port", "8080", "--verbose"]
}

Built-in Functions

print(value)

print(format, ...args)

Prints a value to standard output followed by a newline. When called with a single argument, print outputs the value directly. When called with a format string and additional arguments (up to 25), it performs formatted output with type-checked placeholders.

basic usage
print("Hello, World!")            // Hello, World!
print(42)                            // 42
print([1, 2, 3])                     // [1, 2, 3]
print(true)                          // true
formatted output
print("Name: %s, Age: %n", "Alice", 30)
// Name: Alice, Age: 30

print("Result: %v", [1, 2, 3])
// Result: [1, 2, 3]

print("Score: %n%% out of 100", 95)
// Score: 95% out of 100

Format Specifiers

Specifier Type Description
%v any Auto-format any value (no type check)
%s string String value (type-checked)
%n number Number — integers print without decimals (type-checked)
%b bool Boolean — prints true or false (type-checked)
%l list List value (type-checked)
%m map Map value (type-checked)
%t struct Struct instance (type-checked)
%e enum Enum value (type-checked)
%f function Function value (type-checked)
%r reference Reference value (type-checked)
%% Literal percent sign
Type-checked specifiers raise a runtime error if the argument doesn't match the expected type. Use %v when you don't need type enforcement.

clock()

Returns the elapsed CPU time in seconds as a number. Useful for benchmarking and measuring execution time of code sections.

timing
var start = clock()

var sum = 0
for (var i = 0; i < 1000000; i = i + 1) {
    sum = sum + i
}

var elapsed = clock() - start
print("Took %n seconds", elapsed)

sleep(milliseconds)

Pauses execution for the given number of milliseconds. The argument must be a non-negative number.

delay
print("Starting...")
sleep(1000)  // Wait 1 second
print("Done!")

Native Modules

The CLI extends the core language with native modules for system interaction. These are available only when running scripts through the CLI binary, not in the embedded library.