Essential release reference

ClosedBit Docs

The practical documentation page for writing `.cbp`, compiling artifacts, saving `.cb` files, loading assets, opening HTML UI, and fixing common errors without digging through bloated reference text.

Authoring Rules

Use `.cbp` source. Library declarations go at the top. Normal line-end semicolons are optional. Keep semicolons when writing multiple statements on one line or inside C-style `for (...)` headers.

For real builds, use ClosedBit Studio on Windows. The browser sandbox checks and previews source shape; it does not replace the desktop compiler.

Studio Console

Build actions
help
check
save
compile cba chunky compute threaded max_memory 1024
compile exe small fps graphics threaded usage_high
compile exe small fps graphics threaded usage_high msi
compile dll small compute
compile linux chunky compute threaded
compile library small graphics threaded
decompile
encrypt
encrypt key_file keys\project.key
decrypt key_file keys\project.key
target cba
target exe
target dll
target library
target linux
Action or flagWhat it doesRequirement
helpShows the Studio Console command list.No project file required.
checkRuns the same source-shape checker used before builds.Uses the current editor source.
saveSaves the current editor source.Requires an opened file or a chosen save path.
target cba|exe|dll|library|linuxSets the toolbar output target for the next build.Target must be one of the five listed names.
compile / compile cbaBuilds `.cbp` source into a runnable `.cba` package.Uses current editor when no input path is supplied.
compile exeBuilds a standalone Windows `.exe` with an encrypted source-free runtime package bundled.Can stack with msi; runtime DLL sidecars are generated automatically.
compile dllBuilds a loadable `.dll` that carries an encrypted source-free package.Use for host applications that load ClosedBit packages.
compile linuxBuilds a Linux beta package folder with a `.cba`, Linux runtime launcher, compiled asset sidecars, and `run.sh`.Runs through the Linux beta runtime command.
compile libraryBuilds reusable functions into a `.cbl` package.Library sources should not use fn main() or top-level executable statements.
decompileWrites a normalized `.cbpd` inspection view.Requires a `.cba`; it does not recreate original source.
encryptProtects a `.cba` as an authenticated `.cbe` envelope.Auto-generates a key when none is supplied; custom keys must be at least 256 characters or use key_file.
decryptRestores an encrypted package.Requires the matching key or key_file.
smallCompresses the compiled tree for smaller outputs.Cannot stack with chunky.
chunkyStores the compiled tree raw so launch uses fewer temporary buffers and page faults.Cannot stack with small; output files are larger.
aiSelects the AI/retrieval profile and larger tagged-index cache.Cannot stack with fps.
fpsSelects the low-latency frame presentation profile.Cannot stack with ai; pair with graphics for visual apps.
computeSelects raw runtime compute kernels and higher workload guards.Use for math, physics, and benchmark-style workloads.
graphicsSelects adaptive Direct3D rendering with fallback paths.Use when the program calls window, drawing, or render functions.
threadedEnables runtime worker helpers.Required before threads COUNT has meaning.
threads COUNTRequests 1 to 256 workers without reducing process affinity.COUNT must be a whole number; implies threaded runtime behavior.
max_memory MBSets a guarded private-memory budget.MB must be 1 to 1048576; ignored by uncapped.
usage_highTargets roughly 80% CPU pacing for heavy work.Use only when speed is preferred over quiet background behavior.
uncappedRemoves runtime resource and workload ceilings.Validation, package integrity, and checked overflow still remain active.
msiPackages the generated `.exe` into a Windows installer.Only valid with compile exe; created by ClosedBit's native MSI writer.
Runtime Package screenRuns before every `.cba`, `.exe`, `.dll`, and Linux package launch.Mandatory always-on Runtime behavior. There is no off switch in source, profiles, flags, or build options.
  • Open the Console inside ClosedBit Studio.
  • Choose the output type from the Studio toolbar, then run a build action.
  • `fps`, `ai`, `graphics`, `compute`, and `threaded` select Runtime services.
  • `chunky` makes packages larger but lowers launch memory spikes by avoiding compressed-tree decompression buffers.
  • `usage_high` targets higher CPU use. `uncapped` removes resource ceilings while keeping validation and overflow checks.
  • `msi` stacks only with `compile exe` and packages the standalone executable through ClosedBit's native MSI writer.
  • `compile linux` creates a Linux beta package folder with `run.sh`, a Linux runtime launcher, and compiled asset sidecars.
  • The Runtime Package screen is mandatory before package code starts. It is not an author-controlled command or removable build option.
  • `encrypt` auto-builds or uses the current `.cba`; `decrypt` requires a 256-character key or `key_file`.

Programs

Minimal console program
fn main() {
    println("ClosedBit ready")
    u256 result = (5 + 7) * 3
    save result
}
Checked 256-bit math
library CB-Math

fn main() {
    u256 base = 1_000_000
    u256 bonus = 250_000
    u256 total = base + bonus
    println("total calculated")
    save total
}

Saving

Use `.cb` when the file is a validated ClosedBit storage container. Use ordinary file helpers only when plain text is the goal.

Validated `.cb` save
library CB-Storage

fn main() {
    u256 coins = 1_000_000 + 250_000
    CB-Storage.write_text("player.cb", to_string(coins))
    u256 loaded = parse_u256_or(CB-Storage.read_text_or("player.cb", "0"), zero)
    println("save file checked")
    save loaded
}

Asset Loading

`CB-AssetLoader` accepts common project assets, detects their kind, reads text or Base64 data, copies files into output folders, and returns JSON metadata. It does not pretend every model, shader, image, or video is already decoded into a renderable engine object.

Asset manifest and copy
library CB-AssetLoader

fn main() {
    string asset = "assets/player.obj"
    println(CB-AssetLoader.kind(asset))
    println(CB-AssetLoader.mime(asset))
    println(CB-AssetLoader.manifest(asset))

    if (CB-AssetLoader.is_model(asset)) {
        string copied = CB-AssetLoader.copy_to(asset, "bin/assets/player.obj")
        println("copied: " + copied)
    }
}
  • Images: `.png`, `.jpg`, `.jpeg`, `.bmp`, `.gif`, `.webp`, `.tga`, `.dds`, `.ico`, `.svg`
  • Audio/video: `.wav`, `.mp3`, `.ogg`, `.flac`, `.m4a`, `.aac`, `.mid`, `.midi`, `.mp4`, `.webm`, `.mov`, `.avi`, `.mkv`
  • Models: `.obj`, `.fbx`, `.gltf`, `.glb`, `.stl`, `.dae`, `.ply`, `.3ds`, `.blend`, `.usd`, `.usda`, `.usdc`
  • Materials, shaders, fonts, data, and archives are also recognized and can be copied or read.
  • Every app build also emits `bin/assets/<app>.resources.cb` plus per-asset `bin/assets/compiled/*.cb` and `bin/assets/compiled/*.dll` compiled sidecars.

UI And Rendering

Direct ui.html app
library CB-UI

fn main() {
    CB-UI.html_file("ui.html")
}
Custom error popup
library CB-Popup

fn main() {
    try {
        array rows = [10, 20]
        println(rows[5])
    } catch {
        CB-Popup.error("CB_ERR_ARRAY_INDEX", "The UI asked for a row that does not exist.")
        println(CB-Popup.error_url("CB_ERR_ARRAY_INDEX"))
    }
}
Render loop
library CB-Render

fn main() {
    init_window(960, 540, "ClosedBit Window")
    while (!should_close()) {
        handle_events()
        clear(0x071018)
        draw_text(24, 24, "ClosedBit", 0x64F1AC, 24)
        swap_buffers_fast()
    }
}

Place a real `ui.html` beside the `.cbp` source when you use `CB-UI.html_file("ui.html")`. Runtime opens that HTML as the app GUI while CBP keeps the compile, storage, popup, and runtime logic in one package.

Libraries

Learn the core libraries first: `CB-Console`, `CB-Math`, `CB-Storage`, `CB-AssetLoader`, `CB-UI`, `CB-Render`, `CB-Popup`, networking, security, testing, and logging. The full source catalog is available when you need a specific library, but the essential guide keeps the main workflow small.

Open library source catalog

Create a library
library CB-Library.DataStructures

fn GameScore.score_bonus(u256 score, u256 multiplier) {
    return score * multiplier
}

Account And License

Sign in from the Studio Settings panel or from this portal. The desktop apps protect the session with Windows DPAPI, and the compiler silently verifies product entitlement before each build. If the license service cannot be reached, Studio can use the last locally protected active license until the connection returns.

Customer builds do not require command-line API calls. The account layer runs behind the Studio login and compiler flow.

Error Docs

ClosedBit error pages are published as real URLs for IDE hints, Runtime dialogs, search engines, support links, and AI prompts. The glossary covers every public compiler and runtime error family, including array indexes, package validation, render setup, GPU backend failures, storage, network, license, encryption, and build output.

Open ClosedBit Error Docs

Essential Guide

The essential guide is the source of truth for the current developer workflow. It is deliberately short: write code, check it, compile it, package assets, save data, open UI, handle errors, and ship the artifact.

For deep library details, use the library source catalog. Do not read the full catalog before writing your first app.