Skip to content
BT cat mascot

BT Programming Language

One compact language runtime for scripts, web services, desktop apps, FFI, and extensions.

English · Simplified Chinese · Website · Documentation

Implemented in Rust CLI, Web, and Desktop runtime Windows, Linux, and macOS MIT OR Apache-2.0 license

BT is a compact interpreted programming language implemented in Rust. Its JavaScript-like syntax compiles to register-based bytecode, while one shared runtime powers command-line programs, web services, desktop applications, native FFI, and installable extensions.

Highlights

  • Familiar syntax — JavaScript-like expressions, functions, classes, closures, destructuring, and chainable APIs.
  • Register-based VM — source code is compiled to bytecode before execution.
  • One runtime, multiple targets — build CLI tools, concurrent web services, and packaged desktop applications.
  • Explicit empty-value modelempty means that no value exists; null remains an explicit value.
  • Extensible by design — use native FFI, WASM/WASI extensions, pure BT extensions, and object bindings.
  • Long-running workloads — bounded runtime resources and observable statistics support resident services.

A first look

fn greet(name) {
    'Hello, ' + name
}

// Output: Hello, BT
print greet('BT')

Every BT expression has a runtime result. Multiline blocks return their last statement by default, and return can still exit a function early.

BT also distinguishes two empty states:

  • empty means that a value does not exist, such as a missing field, an out-of-range index, or a function without a result.
  • null is an explicit value used for JSON nulls, database NULLs, or failed conversions.

Quick start

Install the stable Rust toolchain, then run a checked-in BT example directly from the repository:

cargo run --release --bin bt -- -c examples/compat/empty-null.bt

When the current directory contains main.bt, running bt without a source argument executes that file. Otherwise, it starts the interactive prompt.

Run the basic desktop example:

cargo run --release --features desktop --bin bt-app -- run examples/desktop

Build and test

Target Command
CLI runtime cargo build --release --bin bt
Desktop runtime cargo build --release --features desktop --bin bt-app
Default test suite cargo test
Desktop test suite cargo test --features desktop

Windows desktop builds require the MSVC toolchain, the Windows SDK, and the WebView2 Runtime. The Linux and macOS packages used by CI are documented in the release workflow.

Inside a desktop project containing app.json, use the built runtime to create a bundled executable:

path/to/bt-app build

Examples

The catalog below covers every top-level entry in examples/. Some entries are user-facing tutorials, while others are focused regression, stress, or acceptance fixtures.

Language and runtime

Example Description
compat/ Regression scripts for block results, classes and closures, destructuring, empty/null, and snake_case standard-library APIs.
bytes-modbus.bt Builds a Modbus TCP request and parses a binary register response.
permission-stats.bt Validates permission allow/deny configuration and runtime denial counters.
process-pipe.bt Starts a child process and reads its standard output, standard error, and exit information.
reqwest-pool-bench.bt Sends repeated requests to a local HTTP endpoint and reports connection-pool reuse statistics.
runtime-pools-stats.bt Prints configured HTTP and MySQL pool limits and current transaction state.
runtime-stats.bt Reads a minimal snapshot of the shared runtime and bounded I/O configuration.

Networking and web

Example Description
net-phase2-tcp-server.bt Starts an event-driven TCP echo server with connect, message, close, and error callbacks.
net-phase2-tcp-client.bt Connects to the TCP example, exchanges one message, and closes the connection.
net-phase2-udp-server.bt Starts a UDP echo socket and replies to each sender address.
net-phase2-udp-client.bt Sends a datagram to the local UDP example.
net-phase2-ws-server.bt Hosts a WebSocket route with lifecycle callbacks and echo messages.
net-phase2-ws-client.bt Connects to the WebSocket example and handles asynchronous messages.
net-phase3-stats.bt Inspects bounded network queues, message limits, and idle timeout settings.
net-phase3-tcp-burst-client.bt Sends a short burst of TCP requests to validate repeated request/response handling.
net-stress-tcp-server.bt Counts and echoes a sustained TCP message workload for stress validation.
net-stress-tcp-client.bt Drives the TCP stress server across repeated connections and payload batches.
net-stress-udp-server.bt Counts high-volume UDP datagrams until an explicit stop message arrives.
net-stress-udp-client.bt Sends a high-volume UDP workload with numbered payloads.
net-stress-ws-server.bt Echoes and counts WebSocket messages for sustained-connection testing.
net-stress-ws-client.bt Drives the WebSocket stress server and verifies echoed responses.
net-web/ Runs the BT web engine through net.listen({type: 'web'}) with a local site entry.
web-blocking-policy/ Demonstrates which blocking operations are accepted or rejected inside web request handling.
longrun-audit/ Combines a local web service and probe workload for long-running resource audits.

Desktop applications

Example Description
desktop/ A small diary application showing a static frontend and window.bt.call() backend bridge.
desktop-api/ Exercises the public desktop APIs exposed through window.bt.
desktop-dev-reload/ Demonstrates resource watching, exclusion rules, and development-time reload.
desktop-html/ Packages a frontend-only HTML, CSS, and JavaScript desktop application without a BT backend.
desktop-icon-appjson/ Validates an application icon configured through app.json.
desktop-icon-html/ Validates a packaged static application with an HTML entry and ICO asset.
desktop-remote/ Loads a remote web page while retaining the local BT bridge.
desktop-server/ Starts a local BT server and loads it inside a desktop window.
desktop-starter-cdp/ Provides a generated starter project used for WebView2 CDP bridge acceptance.
desktop-starter-auto-cdp/ Exercises automated starter creation and the first CDP launch flow.
desktop-starter-auto-cdp2/ Repeats the automated starter/CDP flow to cover subsequent-launch behavior.

Extensions, FFI, and devices

Example Description
device-serial.bt Scans available serial ports through the device API.
ext-install-demo/ Uses an installed SQLite extension to create, write, and query a local database.
extension-development/ Contains extension-development projects for BT, shared runtimes, and SQLite/WASM packaging.
ffi-testlib/ Calls the cross-platform native test library with explicit FFI signatures and long-running checks.
ffi-user32/ Demonstrates Windows user32.dll calls with inferred and explicit FFI signatures.

Repository layout

Path Purpose
.github/ Public CI workflows, contribution guidance, and README assets.
src/ Lexer, parser, compiler, bytecode VM, standard library, web runtime, desktop runtime, and bundle support.
src-tauri/ Tauri configuration, permissions, capabilities, and the minimal compile-time frontend placeholder.
crates/ The extension SDK and the native FFI test library used by the Cargo workspace.
src-tauri/icons/ Compile-time icons embedded in bt and bt-app.
examples/ Runnable language, extension, web, and desktop examples used by contributors and CI.
benches/ Repeatable quality and performance workloads.
tools/quality/ Public regression, benchmark, and long-running validation scripts.

Documentation and contributing

License

BT is licensed under either of

at your option. See COPYRIGHT for copyright ownership. Binary release archives include a target- and feature-specific THIRD-PARTY-NOTICES.txt; bundled extension packages carry their own notices.

About

The BT programming language

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages