# sunbit **Repository Path**: gzcloud/sunbit ## Basic Information - **Project Name**: sunbit - **Description**: AI时代的编程语言 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: zig-v2 - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-02 - **Last Updated**: 2026-05-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Sunbit v2 [English](README.md) | [简体中文](README-zh.md) Sunbit is a systems programming language with the file extension `.sun`. > **Design philosophy: Rust's safety + Zig's simplicity + zero annotations** > > Compile-time ownership and borrow checking, automatic provenance tracking, > no GC, no ARC, zero runtime overhead. ## Highlights - **Move + Borrow memory model** — assignment is move, parameters are auto-borrowed, all checked at compile time - **Zero lifetime annotations** — automatic provenance tracking, no `'a` to write - **Embedded-friendly** — precise integer types (`i32`/`u16`), `@packed`/`@extern` layouts, `heap=false` build target - **Zero-cost C interop** — `extern "C"` is fully ABI-compatible - **No macros** — variadic functions, f-strings, `@`-attributes and `comptime` cover the use cases macros usually solve - **AI-native (planned)** — first-class `Tensor` type and GPU acceleration ## A first taste ```sunbit fn main() { println("Hello, Sunbit!") } ``` ```sunbit @Derive(Copy) struct Point { x: float, y: float, } fn main() { const p1 = Point { x: 1.0, y: 2.0 } const p2 = p1 // Copy: p1 still valid println(p1.x) // 1 println(p2.y) // 2 } ``` More samples live under [`examples/`](examples/) — ownership, borrow, traits, generics, collections, error handling, closures, operator overloading. ## Project layout (Zig-based v2 rewrite) ``` src/ main.zig CLI entry point root.zig top-level glue module ast/ AST definitions ir/ shared IR data types lexer/ lexer parser/ recursive-descent parser printer/ AST printer hir/ mir/ high- and mid-level IR sema/ semantic analysis lowering/ AST → HIR → MIR lowering codegen/ LLVM-C code generator driver/ compilation driver (build / run / test / emit) std/ standard library written in Sunbit (.sun) docs/ language spec & design notes examples/ example programs packages/ companion packages (e.g. sunview) ``` ## Build & test The compiler itself is written in Zig and links against LLVM (Homebrew path `/opt/homebrew/opt/llvm`, dynamic `LLVM-22`). Make sure both are installed, then: ```bash zig build # build the compiler zig build test # run the Zig test suite ./zig-out/bin/sunbit version # version info ./zig-out/bin/sunbit parse examples/01_hello.sun # print the AST ./zig-out/bin/sunbit run examples/01_hello.sun # compile and run ``` CLI commands: | Command | Description | | ----------------- | -------------------------------------------- | | `build ` | compile to a native executable (`-o output`, `--release`) | | `run ` | compile and execute (`--release`) | | `parse ` | parse and print the AST | | `lex ` | lexical analysis only | | `test `| run tests, supports `@expect-error` negative tests | | `emit-hir ` | emit the HIR for a file | | `emit-mir ` | emit the MIR for a file | | `version` | print version information | Running `sunbit build` without a file falls back to `src/main.sun` of the project containing a `sunbit.toml`. ## Roadmap - [x] Phase 1 — Lexer + Parser + AST + Printer + CLI - [x] Phase 2 — Semantic analysis + LLVM AOT codegen - [x] Phase 3 — Ownership + Borrow checking + Provenance - [x] Phase 4 — Trait + Generics + Operator overloading - [ ] Phase 5 — Concurrency (`task` / `Chan` / `select`) - [ ] Phase 6 — `Tensor` / GPU ## Further reading - Language reference: [`docs/sunbit-v2-syntax.md`](docs/sunbit-v2-syntax.md) - Compiler pipeline: [`docs/pipeline.md`](docs/pipeline.md) - Architecture review: [`docs/architecture-review.md`](docs/architecture-review.md) - Standard library notes: [`std/README.md`](std/README.md)