System API
Properties of the host machine and the running process: OS and device identity, hardware info, well-known directories, blocking sleeps, and live environment manipulation.
Overview
The System API is a namespace exposing properties of the host machine and the running process. It is registered at VM startup as the global identifier System; all methods are invoked as System.method(...).
For per-process subprocess control (spawning, piping stdin/stdout, killing), see Process. System.setEnv / System.unsetEnv mutate the current process's environment, and any process subsequently launched through Process.spawn / Process.exec inherits the updated environment automatically. No plumbing is required to pass values from the script down into a child.
Conventions
All string-returning methods produce UTF-8. On hosts that cannot answer a query (osVersion() on a stripped-down container, for instance) the call returns an empty string rather than null. cpuCount() returns a Zym number (integer-valued), and hasFeature / hasEnv return booleans.
Bad argument types raise a Zym runtime error of the form System.method(args): argument must be a <type>. systemDir(name) raises a runtime error if name is not one of the supported desktop-only kinds. See Conventions for the CLI-wide rules.
Identity
Returns the OS family name, e.g. "Linux", "macOS", "Windows".
Returns the distribution or OS friendly name, e.g. "Ubuntu 25.10", "macOS 14.6", "Windows 11". Returns an empty string if the platform does not expose one.
Returns the version string for the OS. The format is platform-defined.
Returns the device or model identifier as reported by the host. Desktops typically return "GenericDevice".
print("%s %s", System.osName(), System.distribution()) // Linux Ubuntu 25.10
Hardware
Returns the human-readable CPU brand string, e.g. "AMD Ryzen 9 5980HX with Radeon Graphics".
Returns the number of logical CPU cores available to the process.
Returns a stable per-machine identifier. Suitable for non-secret machine fingerprinting; not suitable as a secret.
Locale & Features
Returns the full BCP-47-ish locale tag, e.g. "en_US".
Returns the language portion of the locale only, e.g. "en".
Tests for a runtime feature tag and returns a boolean.
name(string) — feature tag to test, e.g."pc","linuxbsd","x86_64","64","debug"/"release"
if (System.hasFeature("64")) { print("64-bit build") }
Process Info
Returns the absolute path of the currently running zym binary.
Directories
All directory methods return absolute paths as strings. Paths are not guaranteed to exist on disk. Create them before writing.
Returns the per-user, non-project-specific data directory. Linux: $XDG_DATA_HOME or ~/.local/share. macOS: ~/Library/Application Support. Windows: %APPDATA%.
zym is a general-purpose runtime rather than a single project. For per-app isolation, append your own application-name segment to the value of dataDir().
Returns the per-user config directory. Linux: $XDG_CONFIG_HOME or ~/.config.
Returns the per-user cache directory. Linux: $XDG_CACHE_HOME or ~/.cache.
Returns the system temp directory: /tmp on Linux/macOS, %TEMP% on Windows.
Returns a well-known user folder. Only desktop-meaningful folders are accepted; any other value raises a runtime error.
name(string) — folder kind, case-insensitive:"desktop","documents","downloads","movies","music","pictures"
print("downloads: %s", System.systemDir("downloads")) print("documents: %s", System.systemDir("documents"))
Sleep
Both sleep methods block the calling thread and return null.
Blocks the calling thread for ms milliseconds. Negative values are clamped to 0.
Blocks the calling thread for usec microseconds. Negative values are clamped to 0.
var t0 = Time.ticksMsec() System.sleep(250) print("waited %n ms", Time.ticksMsec() - t0)
Environment
The environment methods read and write the current process's environment. Changes take effect immediately and propagate to any subsequent child process spawned via Process.spawn / Process.exec, because those inherit the parent's live environment by default.
Returns the value of name, or null if the variable is not set.
Returns true if name is currently set, false otherwise.
Sets name to value, replacing any prior value. Returns null.
Removes name from the environment. No-op if it was not set. Returns null.
Process.getEnv / Process.setEnv / Process.unsetEnv. They operate on the same underlying process environment as the System versions. Calling either is equivalent; use whichever module reads more naturally at the call site.
setenv / unsetenv are not thread-safe with respect to concurrent reads. Zym is single-threaded, so this is not a concern from script. It matters only when embedding zym alongside multi-threaded native code.
Examples
Identifying the Host
print("%s %s on %s", System.osName(), System.osVersion(), System.cpuName()) print("%n cores, locale %s", System.cpuCount(), System.locale())
Writing to the User's Data Directory
var dir = System.dataDir() + "/my-tool" Dir.makeRecursive(dir) File.writeAllText(dir + "/config.json", "{}")
Passing Environment Values to a Child Process
System.setEnv("MY_TOOL_LOG", "debug") var r = Process.exec("/usr/local/bin/my-tool", ["--check"]) print("exit=%n", r.exitCode) System.unsetEnv("MY_TOOL_LOG")