fn main() {
println("ClosedBit ready")
u256 result = (5 + 7) * 3
save result
}
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.
Studio Console
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 flag | What it does | Requirement |
|---|---|---|
help | Shows the Studio Console command list. | No project file required. |
check | Runs the same source-shape checker used before builds. | Uses the current editor source. |
save | Saves the current editor source. | Requires an opened file or a chosen save path. |
target cba|exe|dll|library|linux | Sets the toolbar output target for the next build. | Target must be one of the five listed names. |
compile / compile cba | Builds `.cbp` source into a runnable `.cba` package. | Uses current editor when no input path is supplied. |
compile exe | Builds a standalone Windows `.exe` with an encrypted source-free runtime package bundled. | Can stack with msi; runtime DLL sidecars are generated automatically. |
compile dll | Builds a loadable `.dll` that carries an encrypted source-free package. | Use for host applications that load ClosedBit packages. |
compile linux | Builds 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 library | Builds reusable functions into a `.cbl` package. | Library sources should not use fn main() or top-level executable statements. |
decompile | Writes a normalized `.cbpd` inspection view. | Requires a `.cba`; it does not recreate original source. |
encrypt | Protects 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. |
decrypt | Restores an encrypted package. | Requires the matching key or key_file. |
small | Compresses the compiled tree for smaller outputs. | Cannot stack with chunky. |
chunky | Stores the compiled tree raw so launch uses fewer temporary buffers and page faults. | Cannot stack with small; output files are larger. |
ai | Selects the AI/retrieval profile and larger tagged-index cache. | Cannot stack with fps. |
fps | Selects the low-latency frame presentation profile. | Cannot stack with ai; pair with graphics for visual apps. |
compute | Selects raw runtime compute kernels and higher workload guards. | Use for math, physics, and benchmark-style workloads. |
graphics | Selects adaptive Direct3D rendering with fallback paths. | Use when the program calls window, drawing, or render functions. |
threaded | Enables runtime worker helpers. | Required before threads COUNT has meaning. |
threads COUNT | Requests 1 to 256 workers without reducing process affinity. | COUNT must be a whole number; implies threaded runtime behavior. |
max_memory MB | Sets a guarded private-memory budget. | MB must be 1 to 1048576; ignored by uncapped. |
usage_high | Targets roughly 80% CPU pacing for heavy work. | Use only when speed is preferred over quiet background behavior. |
uncapped | Removes runtime resource and workload ceilings. | Validation, package integrity, and checked overflow still remain active. |
msi | Packages the generated `.exe` into a Windows installer. | Only valid with compile exe; created by ClosedBit's native MSI writer. |
Runtime Package screen | Runs 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
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.
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.
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
library CB-UI
fn main() {
CB-UI.html_file("ui.html")
}
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"))
}
}
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.
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.
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.
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.