Proposal: OS interface library (Os.*) — args, env, known dirs, exit, platform (Go-inspired, game-scoped) #21

Closed
opened 2026-08-29 20:22:01 +02:00 by orkun · 0 comments
Owner

Summary

An OS interface library, Go-flavored, for the environment around the game:
command-line args, environment variables, standard streams, process exit codes,
working/known directories, and a few process/host facts. Rounds out the bare
Sys.*/arg/getenv/exit builtins into one coherent namespace.

Why it matters for game devs (modestly)

Mostly relevant to tools, launchers, and dev workflows rather than the game
itself — hence low priority:

  • Dev/CLI tools written in Ludic (asset pipelines, the bin/x runner style).
  • Launch flags: --fullscreen, --level 3, --seed 42.
  • Config via env: LUDIC_ASSETS=/path, debug toggles.
  • Known folders: where to put saves, config, cache per OS.

Proposed API (illustrative)

# doc-check: skip — illustrative API sketch
for a in Os.args() { parse_flag(a) }
let assets = Os.env("LUDIC_ASSETS") ?? "assets/"
Os.exit(1)                              # with a status code
let dir  = Os.save_dir("MyGame")        # platform-correct per-user dir
let host = Os.platform()                # "macos" | "windows" | "linux" | "wasm"
Os.stdout_write("hello\n")
  • args, env/set_env, exit, platform/arch, standard streams,
    known directories (save_dir, config_dir, cache_dir, temp_dir),
    maybe now-adjacent host facts.
  • Overlaps with Filesystem for paths — Os provides the locations, Fs the ops.

Considerations

  • Cross-platform: hide per-OS differences; give correct known-folder paths on
    macOS/Windows/Linux. On wasm, most of this is stubbed/virtual — document the
    reduced surface per target.
  • Native/C-free via existing syscall/IR paths.
  • Keep it small and game-relevant; do NOT try to reimplement all of Go's os
    — no process spawning, signals, or user/permission APIs in v1 unless a concrete
    game/tool need appears.
  • Determinism: args/env are non-deterministic input; keep them out of replayable
    simulation.

Scope / acceptance

  • Os namespace: args, env, exit, platform/arch, std streams, known dirs.
  • Correct per-OS known-folder resolution; documented wasm limitations.
  • Docs page + a "parse launch flags" example.
  • Tests where feasible (env round-trip, arg parsing helpers).

Related: Filesystem & IO (paths/ops), Time, Logging, existing Sys.* builtins.

## Summary An **OS interface** library, Go-flavored, for the environment around the game: command-line args, environment variables, standard streams, process exit codes, working/known directories, and a few process/host facts. Rounds out the bare `Sys.*`/`arg`/`getenv`/`exit` builtins into one coherent namespace. ## Why it matters for game devs (modestly) Mostly relevant to **tools, launchers, and dev workflows** rather than the game itself — hence **low priority**: - **Dev/CLI tools** written in Ludic (asset pipelines, the `bin/x` runner style). - **Launch flags**: `--fullscreen`, `--level 3`, `--seed 42`. - **Config via env**: `LUDIC_ASSETS=/path`, debug toggles. - **Known folders**: where to put saves, config, cache per OS. ## Proposed API (illustrative) ```ludic # doc-check: skip — illustrative API sketch for a in Os.args() { parse_flag(a) } let assets = Os.env("LUDIC_ASSETS") ?? "assets/" Os.exit(1) # with a status code let dir = Os.save_dir("MyGame") # platform-correct per-user dir let host = Os.platform() # "macos" | "windows" | "linux" | "wasm" Os.stdout_write("hello\n") ``` - `args`, `env`/`set_env`, `exit`, `platform`/`arch`, standard streams, known directories (`save_dir`, `config_dir`, `cache_dir`, `temp_dir`), maybe `now`-adjacent host facts. - Overlaps with Filesystem for paths — Os provides the *locations*, Fs the *ops*. ## Considerations - **Cross-platform**: hide per-OS differences; give correct known-folder paths on macOS/Windows/Linux. On **wasm**, most of this is stubbed/virtual — document the reduced surface per target. - Native/C-free via existing syscall/IR paths. - Keep it **small and game-relevant**; do NOT try to reimplement all of Go's `os` — no process spawning, signals, or user/permission APIs in v1 unless a concrete game/tool need appears. - Determinism: args/env are non-deterministic input; keep them out of replayable simulation. ## Scope / acceptance - [ ] `Os` namespace: args, env, exit, platform/arch, std streams, known dirs. - [ ] Correct per-OS known-folder resolution; documented wasm limitations. - [ ] Docs page + a "parse launch flags" example. - [ ] Tests where feasible (env round-trip, arg parsing helpers). Related: Filesystem & IO (paths/ops), Time, Logging, existing Sys.* builtins.
orkun added the
proposal
priority:low
area:stdlib
labels 2026-08-29 20:22:01 +02:00
orkun closed this issue 2026-08-30 21:19:17 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: workshopsoft/ludic#21
No description provided.