CLI Reference
The Zym CLI is a single binary that compiles, runs, and packages Zym programs. It is also a worked example of embedding the language, since every native it ships is registered through the same public C API any other host would use.
Quick Reference
| Command | Description |
|---|---|
zym -v, --version | Print the Zym version |
zym -h, --help | Print help |
zym <file> | Run a source, bytecode, or package file |
zym <file.zym> -o <out.zbc> | Compile source to bytecode or a package |
zym <file.zbc> -o <out.zpk> | Pack bytecode into a package |
zym <file> -o <out> | Pack to a standalone executable |
zym <file> -o <out> -r <runtime> | Use an explicit runtime for cross-platform packing |
File Types
.zym: Zym source.zbc: compiled bytecode, portable across platforms.zpk: a package containing bytecode plus any assets it ships with- a standalone executable: the runtime and your program in one file, requiring nothing else installed
All three input forms are interchangeable at the command line: zym inspects what it was handed and does the right thing. The Pack module exposes the same packaging machinery to scripts.
Running Scripts
Write a file and run it directly. There is no build step for the common case.
print("Hello, Zym!")
zym hello.zym
Packaging
A script can be packed into a standalone executable that carries the runtime inside it. The result depends on nothing else being installed on the target machine.
zym main.zym -o my_app
# my_app has the runtime and your code inside
./my_app
Packing across platforms works by pointing at an alternate runtime:
zym main.zym -o my_app.exe -r windows
The one function the CLI registers directly into the global scope, rather than as a member of a module namespace. Everything else lives behind a namespace. See Conventions.
Writes to stdout, followed by a newline. Called with no arguments it prints an empty line. Called with exactly one argument it converts that value to a string and prints it, whatever its type. Called with two or more arguments the first must be a string, and is treated as a format string for the rest; passing a non-string first argument raises a runtime error.
print() // empty line print(42) // any single value, stringified print("%s scored %n", name, score) // format string + arguments
Format specifiers are type-checked: passing a value of the wrong kind raises a runtime error naming the specifier and the position, rather than printing something misleading.
| Specifier | Expects |
|---|---|
%v | any value, stringified without a type check |
%s | string |
%n | number |
%b | bool |
%l | list |
%m | map |
%t | struct |
%e | enum |
Native Modules
Each module is a single global identifier holding a namespace of methods. They are registered at VM startup through the public C API, which means the catalog below is not privileged. A host embedding zym_core registers its own natives exactly the same way.
Conventions
The rules every module follows: identifiers, return shapes, status strings, and byte interop.
Console
Terminal output and input: colors, cursor control, raw mode.
File
Read, write, and manage files, by static helper or open handle.
Dir
Create, list, walk, and remove directories.
Path
Pure-string path utilities that stay portable across platforms.
Process
Run other programs, capture output, send signals, manage the environment.
System
Properties of the host machine and the running interpreter.
Time
Clocks, datetime queries, parsing helpers, and timezone information.
Buffer
Mutable byte arrays with endian-aware reads and writes, compression, and hex interop.
JSON
Standards-compliant JSON encoding and decoding.
RegEx
Compiled regular expressions with PCRE2 syntax.
Hash
MD5, SHA-1, and SHA-256 digests, streaming or one-shot.
Crypto
Random bytes, RSA keys, and certificates, backed by mbedTLS.
AES
AES-128 and AES-256 in CBC and ECB, including encrypted file I/O.
Networking
IP, TCP, UDP, TLS, DTLS, ENet, and WebSocket, covering everything from plain sockets to reliable UDP.
SQLite
An embedded SQL database, modeled closely on better-sqlite3.
Pack
The package format: ship scripts and assets as one file, or as an executable.
Random
Non-cryptographic pseudo-random number generation.
Zym
Nested in-process VMs, each granted a capability-gated slice of this catalog.