Skip to content

A toy programming language you use to build other toys

Notifications You must be signed in to change notification settings

ryanisaacg/brick

Folders and files

NameName
Last commit message
Last commit date
Jan 26, 2025
Mar 1, 2025
Jan 1, 2025
Aug 17, 2024
Dec 25, 2024
Sep 3, 2024
Sep 3, 2024
Mar 1, 2025
Mar 1, 2025
Aug 17, 2024
Aug 17, 2024
Mar 1, 2025
Mar 1, 2025
Mar 28, 2024
Mar 1, 2025
Sep 16, 2024
Aug 13, 2024
Aug 1, 2024
Mar 2, 2025
Aug 9, 2024
Dec 25, 2024
Mar 2, 2025

Repository files navigation

Brick Programming Language

This repo is a work-in-progress programming language inspired by Without Boats' "Notes on a Smaller Rust", Graydon Hoare's "The Rust I Wanted Had No Future", the Austral programming language, and to some degree Typescript/Go (for introducing me to the joy of structural interfaces).

Its principle goal is to be enjoyable to use for writing games and toy software. To that end, it should:

  1. Be fun to write (implementation simplicity drives design decisions; no LLVM backend)
  2. Allow for very fast iteration (compile very quickly, run reasonably quickly; provide facility for easy testing)
  3. Prevent frustrating errors (no null pointers; no aliased mutability; sum types)
  4. Trade a little performance for a little convenience, where necessary (reference-counting; easy copy/clones, etc)

It's just barely ready to write toys in, if you're willing to get your hands dirty: no standard library, no built-in IO of any kind, barely any collections, and a big pile of known bugs.

brick isn't a final name, but it's the one the language goes by for now!

Sub-Crates

  • brick/: Core language code (parse, typeheck, de-sugar, borrowcheck, low-level IR, and a basic tree-walking interpreter)
  • brick-wasm-backend/: Emits WebAssembly, plus a wasmtime-based test harness. Not yet capable of producing linked binaries with rust-runtime
  • brick-runtime/: Rust-based runtime for the language, linked into both the interpreter and the wasmtime test harness
  • runtime-binary/: Helper crate to build brick-runtime for wasm, and provide the runtime bytes to other crates
  • brick-wasmtime/: Helper to create a linked wasmtime module that includes the brick runtime
  • brick-lsp/: A proof-of-concept implementation of the Language Server Protocol, currently all it can do is go-to-definition for functions
  • data-test-driver/: Helper project to run both interpreter and wasm tests over a few hundred test scripts in tests/. Originally they were written via the Rust #[test] handlers but that was slowing compile and testing across two different implementations was difficult
  • brick-fmt/: A proof-of-concept autoformatter. It does produce an output but currently strips comments and whitespace, doesn't break lines, and has many quirks
  • brick-wasmc/: Currently it just compiles a given set of source files into a wasm file, and then dumps the runtime wasm next to it. Ideally it will link to wasm-merge and link the given source files with the runtime, and produce a single linked wasm module.

Setup

This repo requires a recent-ish version of Rust; I've been running it on Rust 1.77.1. You should be able to cargo test from the root and all tests should pass. If you want to play around with a potential change to the compiler, the test suite should be a pretty good guide.

Things are a little blurrier when actually trying to write programs. Out of the box, your best bet is using brick-wasmtime as a scaffold. You can either copy its source or declare it as a dependency. Add whatever external bindings your program might want from its environment and you should be good to go. Currently the browser-deployment process is a little more cumbersome which I'd like to address before writing docs about it.

About

A toy programming language you use to build other toys

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages