A modern, high-performance programming language implemented in Rust, designed with a focus on simplicity, performance, and developer experience.
Brief is a statically-typed programming language with type inference, featuring:
- Indentation-based syntax (like Python) for clean, readable code
- Type inference with optional type annotations (like Go)
- Bytecode VM with register-based architecture for performance
- Rich standard library with built-in data structures (arrays, maps, stacks, queues)
- Object-oriented features with classes and methods
- String interpolation with
&variablesyntax - Comprehensive error messages with precise source locations
- Lexer (
brief-lexer): Full tokenization with support for:- All keywords, operators, and punctuation
- String literals with interpolation (
&name,&obj.field) - Character literals with escape sequences
- Number literals (integers and doubles, including
.5syntax) - Indentation-based blocks (tabs only)
- Line and block comments
- Comprehensive test suite
- Parser (
brief-parser): Recursive-descent parser (planned) - AST (
brief-ast): Abstract syntax tree types (planned) - Bytecode (
brief-bytecode): Register-based bytecode format (planned) - VM (
brief-vm): Interpreter with GC (planned)
- HIR (
brief-hir): Desugaring and name resolution - IR (
brief-ir): Optional SSA-based intermediate representation - Runtime (
brief-runtime): Standard library functions - CLI (
brief-cli): REPL and file execution - Package Manager (
brief-pm): Dependency management - Scheduler: Multi-threaded work-stealing scheduler
- FFI: Safe foreign function interface
- LLVM/Wasm Backend: Optional native code generation
int x // Explicit type declaration str y // String type x := 1 // Type-inferred initialization y := "Hello" // Infers str from literal const z := 10 // Immutable variable dub(x) // Cast to double str(x) // Cast to string x + y // Arithmetic x ** 2 // Power operator x == y // Comparison x && y // Boolean AND x >> 2 // Bitwise shift x++ // Increment x += 1 // Compound assignment if (x == 1) ret "x is 1" else ret "x is not 1" while (i <= 10) print(i) i++ for (i := 0; i < 10; i++) print(i) for (num in array) print(num) match(grade) case 'A' print("Excellent") else print("Other grade") def add(x, y) ret x + y def add(int x, int y) -> int ret x + y def greet(name) print("Hello, &name!") cls dog obj dog(name) // Constructor implicitly sets obj.name = name obj def greet() print("&obj.name says hi.") def bark() print("woof") myDog := dog("sparky") myDog.bark() // "woof" myDog.greet() // "sparky says hi." int[] x // Fixed array x := int[1, 2, 3, 4, 5] // Initialize with values int{} y // Dynamic array int:str{} map // Map with int keys, str values x := int{stk} // Stack x := int{que} // Queue name := "World" print("Hello, &name!") // "Hello, World!" print("Value: &obj.field") // Interpolate object fields - Rust 1.70+ (or latest stable)
- Cargo
# Clone the repository git clone <repository-url> cd Brief # Build all crates cargo build # Run tests cargo test # Build in release mode cargo build --release# Build just the lexer cargo build -p brief-lexer # Run lexer tests cargo test -p brief-lexerBrief/ βββ Cargo.toml # Workspace configuration βββ crates/ β βββ brief-diagnostic/ # Error reporting and diagnostics β βββ brief-lexer/ # Tokenizer β βββ brief-ast/ # Abstract syntax tree types β βββ brief-parser/ # Recursive-descent parser β βββ brief-bytecode/ # Register-based bytecode format β βββ brief-vm/ # Virtual machine interpreter β βββ brief-runtime/ # Standard library β βββ brief-cli/ # Command-line interface βββ docs/ # Documentation βββ tests/ # End-to-end tests Brief follows a clean, modular architecture:
- Lexer β Tokenizes source code into tokens
- Parser β Builds AST from tokens
- HIR β Desugars and resolves names
- IR β Optional SSA-based optimization
- Bytecode β Register-based bytecode generation
- VM β Executes bytecode with GC
- Register-based VM: Better performance than stack-based
- Indentation-based blocks: Cleaner syntax, no braces needed
- Type inference: Reduces boilerplate while maintaining safety
- Direct-threaded dispatch: Fast VM execution
- Inline caches: Optimize method/property lookups
- Quicken: Specialize generic opcodes to typed versions
# Run all tests cargo test # Run tests for a specific crate cargo test -p brief-lexer # Run with output cargo test -- --nocapture- Lexer with full token support
- Parser for expressions and statements
- Basic VM for arithmetic and control flow
- REPL
- Functions and closures
- Arrays and maps
- Classes and objects
- Standard library
- Inline caches
- Opcode quickening
- Garbage collector
- Optimizations
- Multi-threading and scheduler
- Package manager
- FFI support
- Future total web support