A high-performance OOP language that compiles to pure C.
package DEMO
using IO
block global = 64MB
interface Damageable {
fn take_damage(i32 dmg)
}
struct Entity {
i32 hp
String name
fn Entity(i32 h, String n) {
hp = h
name = n
}
}
struct Player extends Entity, Damageable {
i32 ammo
f64 accuracy
fn Player(i32 h, String n, i32 a, f64 acc) {
hp = h
ammo = a
name = n
accuracy = acc
}
fn take_damage(i32 dmg) {
hp -= dmg
print("{0} took {1} damage, hp={2}", name, dmg, hp)
}
}
fn main() {
Player p = Player(100, "Felipe", 30, 0.85f64)
p.take_damage(20)
}
brick run example.brcNo manual gcc invocation needed β brick build and brick run handle everything automatically (compilation, runtime linking, optimization).
- OOP with Braces β Class-like
structwith constructors, methods,extends, andinterface. Syntax inspired by GDScript. - Compiles to Pure C β Readable C code with
#linedirectives for debugging. No VM, no interpreter β just native machine code viagcc -O3. - Block-Based Memory β No
malloc/free, no GC. Declare memory blocks (block name = 64MB) and let the bump allocator do the rest. Allocation takes ~3 CPU cycles. Reset an entire block in ~5 ns. - No Stack for User Data β Everything lives in managed blocks. No stack overflow, no lifetime puzzles. Reset a block to reclaim everything instantly.
- Native Hot Reload β Swap code at runtime via
dlopen+inotify. Function pointer swap is atomic β update game logic without restarting. - TUI Memory Visualizer β ncurses dashboard showing live block state: capacity, usage, peak, allocation count.
- GDB Integration β
#linedirectives map back to.brcsource. Custom commands (info blocks,block <name>) and Python pretty-printers. - VS Code Extension β Syntax highlighting, LSP, and a memory webview panel.
- Cross-Platform β Linux primary. Windows via
mingw-w64. - Fixed-Width Types β
i8/i16/i32/i64,u8/u16/u32/u64,f32/f64,usize/isize. Full compile-time overflow checking, widening rules, and literal suffixes (42u8,3.14f64).
- Linux (or Windows with mingw-w64)
- C++20 compiler (GCC β₯ 11 or Clang β₯ 14)
- SCons (
pip install scons) - ncurses (optional, for visualizer)
git clone https://github.com/nonunknown777/brick.git
cd brick
scons # release build (-O3)
# or
./build-release.sh # full release + VS Code extension packageThe brick binary will be in build/.
# Build and run in one step
brick run examples/hello.brc
# Or build to binary first
brick build examples/hello.brc -o hello
./helloscons test # builds and runs all unit testsbrick --visualize examples/hello.brc # compile, run, show TUI
brick --attach <pid> # attach to running process| Operation | Time | vs malloc/free |
|---|---|---|
| Allocation | ~3 CPU cycles | ~50β200Γ faster |
| Block reset (64 MB) | ~5 ns | 2000Γ faster than free() |
| Thread safety | Lock-free per block | β |
Real benchmark results:
Block alloc: 1,000,000 allocs of 64B in 0.002s β 19.5Γ faster
malloc: 1,000,000 allocs of 64B in 0.039s β baseline
Brick applies 7 optimizations automatically:
| Optimization | What it does | When |
|---|---|---|
| Compile-Time Macros | macro/build/emit β code generation, comptime eval, reflection |
Always |
| Constant Folding | Pre-computes 60 * 1000 β 60000 at compile time |
Always |
| Inline Hints | __attribute__((always_inline)) on every function |
Always |
| SIMD Alignment | aligned(16/32) on float fields for SSE/AVX |
Structs with f32/f64 |
| Pool Allocator | O(1) pool_alloc for types β€ 64 bytes | Every block |
| TLS Blocks | block_set_tls() wired in __brick_init() |
Main thread auto |
| Double-Buffer | Atomic block swap for zero-pause hot reload | On request |
| PGO | Profile-guided optimization via scons profile=pgo-* |
Release builds |
See docs/OPTIMIZATIONS.md for deep-dive explanations with examples.
Generate code at compile time with macro, build, and emit:
macro swap(a, b) {
__tmp = $a
$a = $b
$b = __tmp
}
fn main() {
x = 10; y = 20
swap(x, y) // x=20, y=10
}
macro name(params) { body }β definable code templates with$interpolationbuild { }β compile-time code execution (math, loops, type reflection)emit { code }β generate output from inside macros or build blocks$name/$(expr)β insert argument values or computed expressions- Varargs β
values...captures remaining arguments as a list - Hygiene β
__-prefixed variables get unique names automatically
See the Macro Guide for complete examples.
| Input | Compile Time |
|---|---|
| 100 structs | 5 ms |
| 1,000 lines | ~10 ms |
package TYPES_DEMO
using IO
block global = 64MB
interface Drawable {
fn draw()
}
struct Shape {
u32 id
f64 area
fn Shape(u32 i, f64 a) {
id = i
area = a
}
}
struct Circle extends Shape, Drawable {
f32 radius
fn Circle(u32 i, f32 r) {
id = i
radius = r
area = 3.14159f64 * r * r
}
fn draw() {
print("Circle #{0} radius={1} area={2}", id, radius, area)
}
}
fn main() {
Circle c = Circle(1u32, 5.0f32)
c.draw()
}
# Build with hot reload support
brick build game.brc --release -o game
# Run β Brick watches source files via inotify
# Edit your .brc source and save β the binary reloads automatically
./gameSee the Hot Reload Guide for details.
| Directory | Contents |
|---|---|
src/ |
Compiler in C++20 (Lexer, Parser, Codegen) |
runtime/ |
C runtime (block memory allocator, IO, hot reload) |
visualizer/ |
ncurses TUI for live memory visualization |
debugger/ |
GDB pretty-printers, custom commands, .gdbinit |
examples/ |
Sample .brc programs |
tests/ |
Unit tests (SCons-based) |
benchmarks/ |
Performance benchmarks and profiling scripts |
vscode-ext/ |
VS Code extension (syntax highlight, LSP, memory view) |
docs/ |
GitHub Pages site (HTML + assets) |
wiki/ |
GitHub Wiki source |
tasks/ |
Development task breakdown (01β11) with per-task state |
build/ |
Build output directory |
scripts/ |
Utility scripts for testing, profiling, and release |
- Getting Started β Installation, first program, CLI usage
- Language Reference β Complete syntax, types, packages, memory model
- Architecture β How compiler, runtime, and tools fit together
- Hot Reload Guide β Live code swapping via dlopen + inotify
- Macro Guide β Compile-time code generation with
macro/build/emit - Optimizations β Performance tuning and benchmarks
- Design Doc β Architecture decisions and rationale
- π§π· PortuguΓͺs β DocumentaΓ§Γ£o em portuguΓͺs
The project is divided into 11 tasks, each with its own AGENTS.md and STATE.md:
| # | Task | Description |
|---|---|---|
| 01 | Lexer | Tokenizer β .brc β tokens |
| 02 | Parser | AST construction + package resolution |
| 03 | Codegen | Type checking + C code generation with #line |
| 04 | Runtime | Block memory allocator (C) |
| 05 | Hot Reload | dlopen + inotify swap |
| 06 | Visualizer | ncurses TUI dashboard |
| 07 | Builder | SCons build system |
| 08 | VS Code Ext | Syntax highlighting, LSP, debug webview |
| 09 | Debugger | GDB pretty-printers, custom commands |
| 10 | Tester/Opt | Tests, profiling, optimization, docs (senior) |
| 11 | Libraries | Window, input, audio, file, net, math |
Join the discussion β open an issue or PR at github.com/nonunknown777/brick.
BriCk is a play on words in three layers:
- Brick (tijolo) β blocos de memΓ³ria sΓ£o os tijolos que constroem o runtime
- C no meio β compila para C
- BR na frente β Brasil, a origem do projeto
BriCk β the brazilian C.
This project is licensed under the MIT License. See LICENSE for details.
Built with β€οΈ in C++20 and C β because sometimes you need to go fast.
