bop-lang 0.2.0

A small, dynamically-typed programming language
Documentation
  • Coverage
  • 10.95%
    23 out of 210 items documented0 out of 48 items with examples
  • Size
  • Source code size: 159.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 11.94 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 41s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • stevepryde/bop-lang
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • stevepryde

bop

A small, dynamically-typed programming language, designed for learning to code.

Documentation

Note: Bop is experimental and has not been battle-tested. Do not use it in production or mission-critical environments.

Features

  • No dependencies
  • Simple, expressive syntax
  • Functions with recursion
  • Arrays, dictionaries, and string interpolation
  • Built-in resource limits (step count, memory) for safe embedding
  • Embeddable via the BopHost trait
  • Easy to learn, with helpful error messages

Examples

// Variables and string interpolation
let name = "world"
print("Hello {name}!")

// Functions
fn fizzbuzz(n) {
    if n % 15 == 0 { return "FizzBuzz" }
    if n % 3 == 0 { return "Fizz" }
    if n % 5 == 0 { return "Buzz" }
    return str(n)
}

// Loops and arrays
let results = []
for i in range(1, 16) {
    results.push(fizzbuzz(i))
}
print(results.join(", "))

// Dictionaries
let player = {"name": "Ada", "hp": 100}
player["hp"] -= 20
let name = player["name"]
let hp = player["hp"]
print("{name} has {hp} HP")

// Built-in methods
let words = "the quick brown fox".split(" ")
words.sort()
print(words.join(", "))  // brown, fox, quick, the

Quick start

cargo install bop-cli

Run a file:

bop script.bop

Or start the REPL:

bop

Embedding

Add bop-lang to your Cargo.toml:

[dependencies]
bop-lang = "0.2"
use bop::{run, BopLimits, StdHost};

fn main() {
    let mut host = StdHost;
    run("print(1 + 2)", &mut host, &BopLimits::standard()).unwrap();
}

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.