bop-lang
The core of Bop — a small, dynamically-typed, embeddable scripting language for Rust applications.
Hand your users or your AI a real programming language at runtime, without shipping a compiler to the target machine.
Note: Bop is experimental and not yet battle-tested. Fine for tooling, scripting, and embedding experiments; use with care in production.
What's in this crate
bop-lang is the language core:
- Lexer + parser producing a typed AST
- Tree-walking interpreter (
bop::run) — simplest runtime, works everywhere BopHosttrait — the only thing embedders need to implement to wire Bop into their Rust appValuetype + builtin operators — the shared runtime surface every Bop engine uses- Resource limits (
BopLimits) — step count and memory caps for safe sandboxing
For a faster runtime (2–3× this crate's tree-walker, same semantics), add bop-vm. For an AOT path to native Rust, see bop-compile.
Selling points
- Embeddable. One trait (
BopHost) to implement; everything else is handled by the engine. - Zero Rust deps Nothing to audit in your supply chain.
no_stdsupport via theno_stdfeature (uses thelibmcrate internally for float math, nothing else).- WASM-compatible. Builds clean for
wasm32-unknown-unknown. Use it in browsers, edge workers, or wherever you can run Rust. - Sandboxed by default.
BopLimitscaps step count and memory so a runaway user script can't hang or OOM your process.
Quick start
[]
= "0.3"
use ;
;
Features
| feature | default | what it does |
|---|---|---|
bop-std |
yes | bundles the Bop stdlib (use std.math, std.json, std.collections, std.iter, std.string, std.test) as &'static str constants reachable via [bop::stdlib::resolve] |
no_std |
no | opt in for bare-metal / embedded / edge wasm targets. Pulls in libm for float math. Enable with default-features = false, features = ["no_std"] (add "bop-std" too if you want the bundled stdlib on those targets). |
A truly minimal build — core language only, no bundled stdlib:
= { = "0.3", = false }
WASM example
[]
= { = "0.3", = false, = ["no_std", "bop-std"] }
Build for wasm32-unknown-unknown as usual. See bop-vm for the faster runtime if you need it.
Related crates
bop-vm— bytecode compiler + VM, 2–3× faster than this crate's walker, same APIbop-compile— AOT Bop → Rust transpiler for native-speed scriptsbop-sys— ready-madeStdHostwith filesystem / stdio / env / timebop-cli— thebopcommand-line tool (bop run,bop compile, REPL)
License
Dual-licensed under MIT or Apache 2.0, at your option.