Frequently Asked Questions (FAQ)
What is the Xu programming language?
Xu is a statically typed systems language with custom native and WebAssembly AOT backends. It combines inferred ownership, borrow checking, and deterministic cleanup without a garbage collector, plus built-in coroutines (xu f()) and typed channels (chan T).
Does the Xu compiler use LLVM? Why a custom native backend?
No, Xu does not use LLVM. The compiler uses its own MIR (Middle Intermediate Representation), register allocator, and code emitters for Mach-O, ELF, PE, and WebAssembly. Native modules and desktop builds can require host libraries and a matching C toolchain; see native modules and the desktop build requirements.
Does Xu use a garbage collector (GC)?
No. Xu uses inferred ownership and RAII cleanup to release resources deterministically at scope exit, without a runtime garbage collector. Ownership and shared (&T) / exclusive ($&T) borrow checks prevent classes of lifetime and aliasing errors in checked Xu code.
Shared mutable state in concurrent code still requires appropriate synchronization. Native code, FFI, and concurrent libraries have their own safety requirements; these checks do not guarantee that every program is free of data races, leaks, or undefined behavior. Allocation, scheduling, and I/O can still cause latency variation. See Ownership & Borrowing, Concurrency, and native module boundaries.
How does Xu compare to Rust and Go?
Xu infers ownership and uses deterministic cleanup without explicit lifetime annotations such as <'a>. It offers Go-like coroutines and typed channels while using ownership and borrow checking instead of a garbage collector. See the safety boundaries above and the benchmark dashboard for measured runtime and memory results.
How fast are Xu's compilation speed and runtime throughput?
Reproducible performance measurements: compare Xu with C, Rust, Go, and Swift across 60 groups with 72 workload variants on six ARM64 and x86-64 platforms. The benchmark dashboard reports per-platform runtime, CPU time, peak memory and binary size; C and Rust use the lowest measured O1–O3 median for each workload. Compilation timings are available in the source CI reports.
Does Xu support WebAssembly (WASM) out of the box?
Xu 0.13.1 emits wasm32-wasi modules for WASI runtimes. The browser Playground uses a client-side interpreter built with Xu 0.13.1.
Does Xu support native desktop UI? Is WebView required?
Yes, and WebView is optional. The current Xu 0.13.1 release SDK offers two approaches: native drawing and controls through #ui/draw, #ui/layout, and #ui/widgets; or HTML/CSS/JavaScript interfaces hosted by #ui/webview, with a request bridge to Xu. Native control examples require no HTML, CSS, or JavaScript.
#ui provides windows, events, menus, trays, multiple windows, clipboard access, and file dialogs. Xu draws its controls on a native Canvas; system menus and dialogs use the host appearance. Start with the UI / WebView guide and control API and examples.
Which controls, text input features, and themes are available?
The SDK includes buttons, checkboxes, switches, radio buttons, sliders, steppers, tabs, lists, and selectors. Input / TextArea use native text sessions with IME, selection, and clipboard editing. Other components include Table, TreeView, Pagination, ComboBox, MultiSelect, DatePicker, TimePicker, ColorPicker, Popover, Tooltip, Toast, and Modal.
Controls share dark, light, and high-contrast themes with font and text scaling, density, state styles, and local overrides. Retained layout and the Screen context help manage controls, focus, events, and repainting. See the style guide and runnable examples for drawing, editing, and themes.
widgets.ActionDispatcher uses a typed function table to dispatch semantic actions by control id and action kind. Applications can pass actions produced by XACP ui.act on a registered Screen to the same dispatcher; see the control API and ActionDispatcher guide.
Which desktop platforms are supported, and what must I install?
Desktop hosts cover macOS, Windows, and Linux. macOS uses AppKit, with WebKit for web content. Windows uses a native host, with WebView2 for web content. Linux uses GTK4, plus WebKitGTK 6.0 for web content. Building and packaging require the corresponding host toolchain; native drawing and controls do not require the application to embed a WebView.
Run xu doctor --desktop to check dependencies, adding --webview for WebView applications. An application directory contains xu.xun, main.xu, and an application icon; package it with xu build <AppDir> --desktop. See the complete build instructions. Compiler target support does not establish desktop UI runtime coverage, and the browser WASM playground does not run desktop UI. See Status & Limitations.
What are the current limits of native UI?
The components cover common desktop interactions with defined limits. Input / TextArea edit plain text. Table holds bounded data, with sorting and fetching handled by the application. Lists and trees do not build items on demand for unbounded data. Rich text, advanced tables, draggable workspaces, and a complete accessibility bridge need further development.
Text shaping, IME, and system services also require interaction checks on real target systems; successful cross-compilation alone does not establish runtime behavior. Check each API contract and example before choosing a component.
Which editors support Xu, and how do I enable LSP?
The official vscode-xu extension supports VS Code and Cursor. It runs xu lsp to launch the SDK's xu-lsp language server for diagnostics, completion, go-to-definition, hover documentation, document symbols, references, rename, and formatting.
Other LSP-compatible editors can configure xu lsp as their server command, communicating over stdin/stdout using JSON-RPC 2.0. The editor normally starts the server automatically; run xu lsp --help for help.
What is the difference between xu get and xu install?
In a project directory containing xu.xun, run xu get <module>@<version> to add or update a pinned dependency. It edits require:, installs sources into vendor/, and updates xu.lock. Replace the placeholders with a real module and verified published SemVer tag; @latest is not accepted. For official packages, select the SDK bundle or matching fixed source commit and run xu install.
xu install installs dependencies already declared in the manifest. Both commands support --offline; use xu build . --frozen to build strictly against the existing lockfile. See Modules & Dependencies; the official packages repository provides 29 extension packages.
How do I use xu native to integrate C code?
xu native covers the native module workflow: xu native compile compiles C sources with interface metadata into a .a archive; xu native archive wraps existing object files with metadata; xu native pack bundles target slices into .xulib; xu native inspect and xu native extract inspect and extract slices.
Use .a for a single target, or .xulib to distribute interface contracts with multiple target slices. On macos-arm64 or macos-x64, pass the library directly to the build, for example xu build main.xu native/mylib.xulib -o app. Other targets require XUOBJ emission, object conversion, and external linking. Compiling C sources requires the corresponding C toolchain. See Native Modules & .xulib for full examples, or run xu native compile --help.
What operating systems and CPU architectures are supported?
Code generation targets include macOS arm64/x64, Linux arm64/x64/loongarch64/riscv64, Windows x64/arm64, and WebAssembly (wasm32-wasi), with Thumb and RISC-V bare-metal targets listed in Status & Limitations. Downloadable SDK assets are listed on the download page. Emission support and an available SDK do not establish tested runtime or GUI behavior; paths without target-machine acceptance results remain unverified. Check status and per-package limits for the intended target.
What is XACP?
XACP (Xu Agent Control Protocol) is the framed control channel for a hosted native program built with xu build --xacp and/or --xacp-port PORT. That build embeds discovery. ./app --xacp-help prints a machine-readable summary whose capabilities line is stdio, and which says whether TCP is enabled and which address it would bind. This replaces the earlier help-only discovery text.
#xacp (src/xacp) is the transport-neutral safety core: frame and XUN checks, permissions, and session lifetime. Importing #xacp does not install the startup control entry. Stdio and loopback TCP are runtime hooks inserted by the --xacp build. The launcher is xu xacp, which runs the sibling xu-xacp tool. Modes are inspect, run, debug, record, control, attach, and connect. The API is included in the published 0.13.1 SDK extract; this contract follows the matching release source. Native sessions and platform/UI runtime acceptance remain unverified. See the CLI reference, the #xacp API, and the matching release source.
How do XACP stdio and loopback TCP differ?
stdio. Start the target with --xacp-stdio, or run xu xacp control <program>. The session owns stdin and stdout. Frames use XACP/1\n<N>\n followed by exactly N UTF-8 body bytes of plain XUN. Body newlines count; the prefix does not. There is no closing delimiter. The transport strips the prefix before parse_frame; see the exact byte examples. Business main does not run.
Loopback TCP. Build with --xacp-port N where N is 1..65535, then run <app> --xacp-tcp. The process listens only on 127.0.0.1:N. In another terminal, xu xacp connect PORT relays the same frames, one request and one response at a time. Port 0 disables TCP (tcp: disabled (port 0) in discovery) while leaving the stdio capability in place. Each accepted connection is its own session. Connections are handled one at a time; a failed peer ends that session and the listener stays up. Stdio exits when its session ends. The first control flag before -- wins. A normal start does not listen and does not read control stdin.
What does xacp.hello grant?
A control session starts with no permissions. The first request must be xacp.hello, carrying id: !i 1, ver: !ver 1.0.0, and a nonempty nonce. Without a nonempty host XU_XACP_TOKEN, allowed permissions are only PERM_INFO (1), even if the client supplies a token or the host sets XU_XACP_ALLOW_RAW=1. With a nonempty host token, hello must supply it through token, checked in constant time using crypto/subtle.constant_time_compare; missing, empty, or mismatched tokens return auth_failed and close the session. A match allows mask 15 by default; only the exact host setting XU_XACP_ALLOW_RAW=1 allows 31. Optional permissions: !i 0..31 requests permissions, with the actual grant computed as requested & allowed; omission requests the whole allowed mask.
Development permissions are explicit host policy; stdio and TCP transports do not enable them automatically. Permissions cannot change after OPEN, and schema, frame-size, window, and lifecycle checks still apply. Nonce replay checking is enabled by default and runs after authentication and permission validation; a detected replay returns nonce_replay with the same request id, clears the session, and disconnects without entering OPEN. A success frame contains integer id: !i and ok: !b true; its data contains state: OPEN, a path-filtered and quoted nonce, granted integer permissions: !i, and permission_label: none for mask 0, info for 1, development for 31, otherwise custom. proc.output depends on host output capture support, independently of Screen registration. The exclusive startup adapter has no registered Screen, so authorized UI operations return not_implemented; after library attachment, the application can register and keep polling its Screen to handle UI operations through Screen marshalling, subject to the limits below.
How do xu xacp control and xu xacp run differ?
xu xacp run <program> -- args... starts the program so business main runs. The tool inserts an extra --, so a business argument named --xacp-help does not trigger discovery. debug prints --xacp-help first, then runs the same way. It is not a breakpoint debugger. record streams at most 1 MiB of stdout on Unix; stderr stays on the terminal. That file is not an XACP UI recording, and Windows record is still unavailable. inspect runs --xacp-help and accepts no business arguments. It does execute the target.
control starts --xacp-stdio, inherits the caller's stdin and stdout, skips business main, and accepts no business arguments. connect PORT does not take a program path. It relays frames to 127.0.0.1:PORT. User arguments for run, debug, and record must follow the tool's --.
What are the XACP security limits?
Point the launcher only at a trusted local executable. inspect executes it too. There is no TLS and no bind address other than 127.0.0.1. The generator allows hosted native executables only: it rejects libraries, shared objects, test harnesses, embedded targets, and --desktop. Without a nonempty XU_XACP_TOKEN, only INFO read-only access is allowed; control capabilities require setting XU_XACP_TOKEN.
Exclusive startup adapters (--xacp-stdio, --xacp-tcp, or xu xacp control) skip business main and have no registered Screen, so authorized UI operations return not_implemented. Library xacp.attach_stdio() / xacp.attach_tcp(port) lets application main run, with the application registering a Screen and continuing to call xacp.poll. The operations ui.tree, ui.screenshot, ui.input, ui.act, and ui.record access the live UI through Screen marshalling. Closing or unregistering the Screen returns stale_window to waiting requests; later UI requests return not_implemented. xu xacp attach <program> -- args... launches the application with a safe -- argument boundary; application code must still call the attach API.
Under the dev protocol, a registered Screen lets ui.record complete bounded XAR1 sampling within one request, returning mode, records, bytes, truncated, and payload. Requests require positive win and mode: events|frames, with optional max_bytes, max_records, and duration_ms. Clients pull successive segments by repeating requests; each request has one response, with no persistent recorder or continuation cursor. stream_required is reserved for adapters without a sink/sampling capability; the supplied Screen sampling path does not return it.
events currently reports observations of the current window/canvas/generation/open state labelled state=true, with no real input event log; sampling neither injects input nor pumps the application's event loop. frames returns dimensions only with redacted=true, without pixels. CLI xu xacp record records stdout, separately from UI sampling through ui.record. See the API recording guide for argument bounds, truncation, and errors.
proc.output on 64-bit POSIX generated hosts with --xacp instrumentation captures Xu runtime print / eprint and fd 1/2 writes through the runtime fd-write path. It does not capture writes from foreign native code or child processes. Windows and uninstrumented builds return not_implemented; calling the attach API alone does not add output capture.
XU_XACP_WRITE_TIMEOUT_MS defaults to 10000 ms, with a range of 1..600000. It times each complete outgoing frame; partial write progress does not renew the deadline. Expiry is a transport failure: no further frame is sent and the session closes. Exclusive stdio exits nonzero; TCP drops only that peer and continues listening. Stderr prints xacp: write timed out after W ms, where W is the configured value. Windows pipe or console stdio write deadlines are best effort; a blocking write can still wait indefinitely.
The write deadline is independent of read-side XU_XACP_HELLO_TIMEOUT_MS (default 5000 ms), XU_XACP_IDLE_TIMEOUT_MS (default 60000 ms, 0 disables it), and the attached UI wait deadline XU_XACP_REQUEST_TIMEOUT_MS (default 5000 ms). xu xacp connect has no application-level response deadline of its own; the caller remains responsible for an overall process timeout. See the #xacp API and XACP protocol specification for the full contract.
Get Started · UI / WebView · Modules & Dependencies · Native Modules & .xulib · Editor Support · CLI / XACP · #xacp API