diff --git a/PLAN.md b/PLAN.md index 49a2740..e60a9ff 100644 --- a/PLAN.md +++ b/PLAN.md @@ -652,36 +652,37 @@ bux/ | Selfhost fix | โœ… | Build via `build/selfhost/` (project wrapper) | | Push to GitHub | โœ… | `ac969b3` โ€” v0.3.0 restructure | -### 10.1 โ€” Selfhost Loop ๐Ÿ”„ (v0.4.0 target) +### 10.1 โ€” Selfhost Loop โœ… (v0.5.0 target) **Goal:** `buxc2` can compile itself producing a binary-identical `buxc3`. ``` -buxc (Nim) โ†’ src/*.bux โ†’ buxc2 โœ… (already works) -buxc2 โ†’ src/*.bux โ†’ buxc3 ๐Ÿ”„ (needs verification) -buxc2 == buxc3 ๐Ÿ”„ (deterministic codegen) +buxc (Nim) โ†’ src/*.bux โ†’ buxc2 โœ… +buxc2 โ†’ src/*.bux โ†’ buxc3 โœ… +buxc2 == buxc3 โœ… (binary-identical) ``` | Task | Status | Details | |------|--------|---------| -| `10.1.1` Verify buxc2 can build src/ | ๐Ÿ”„ | Run `buxc2 build` on the selfhost project | -| `10.1.2` Deterministic C codegen | โณ | Remove timestamps, random IDs, non-deterministic ordering | -| `10.1.3` Binary-identical loop | โณ | `make selfhost-loop` โ€” 2-pass bootstrap verification | -| `10.1.4` Remove hardcoded paths | โณ | No `/home/ziko/...` paths in cli.bux | +| `10.1.1` Verify buxc2 can build src/ | โœ… | `buxc2 build` works on selfhost project | +| `10.1.2` Deterministic C codegen | โœ… | C output identical on every iteration | +| `10.1.3` Binary-identical loop | โœ… | `make selfhost-loop` passes (C + ELF parity) | +| `10.1.4` Remove hardcoded paths | โœ… | Paths resolved via `bux_getcwd()` / `bux_path_join()` | | `10.1.5` Selfhost test in CI | โณ | Add to `make test` | -### 10.2 โ€” Gradual Ownership ๐Ÿ”„ (v0.5.0 target) โญ Killer Feature +### 10.2 โ€” Gradual Ownership โœ… (v0.5.0 target) โญ Killer Feature -**Goal:** `@[Checked]` functions get full borrow checking. Without this, Bux is "C with modern syntax." +**Goal:** `@[Checked]` functions get full borrow checking. `@[Release]` disables checks for zero-cost hot paths. | Task | Status | Details | |------|--------|---------| -| `10.2.1` `@[Checked]` attribute gate | โณ | Enable/disable borrow checker per function | -| `10.2.2` `&T` shared reference check | โณ | No mutation through shared refs | -| `10.2.3` `&mut T` exclusive mutable check | โณ | No aliasing of mutable refs | -| `10.2.4` Bounds checking on slices | โณ | Buffer overflow prevention | -| `10.2.5` Lifetime elision (simple rules) | โณ | 80% of cases without annotations | -| `10.2.6` Explicit lifetimes `'a` | โณ | Only for complex cases | +| `10.2.1` `@[Checked]` attribute gate | โœ… | Enable/disable borrow checker per function | +| `10.2.2` `&T` shared reference check | โœ… | No mutation through shared refs | +| `10.2.3` `&mut T` exclusive mutable check | โœ… | No aliasing of mutable refs | +| `10.2.4` Bounds checking on slices | โœ… | `Slice_Get` / `Array_Get` with `bux_bounds_check` | +| `10.2.5` `@[Release]` zero-cost mode | โœ… | Disables borrow + bounds checks, passes `-O3 -flto` | +| `10.2.6` Lifetime elision (simple rules) | โณ | 80% of cases without annotations | +| `10.2.7` Explicit lifetimes `'a` | โณ | Only for complex cases | ### 10.3 โ€” Compiler Architecture Upgrade (v0.6.0 target) @@ -854,11 +855,12 @@ func Main() -> int { | **M8** | 8-9 | โœ… | **Borrow checker**, **CTFE**, **Package manager** working | | **M9** | 8.5 | โœ… | **Trait bounds** (``) โ€” semantic checking implemented | | **M10** | 10 | โœ… | **LIR backend** replaces HIRโ†’C; 26/26 examples pass; selfhost builds | -| **M11** | 11 | ๐Ÿ”„ | Selfhost loop: `buxc2` compiles itself โ†’ binary-identical `buxc3` | -| **M12** | 11.3 | โณ | `@[Checked]` borrow checker works on real code | -| **M13** | 11.4 | โณ | `bux test`, `bux fmt`, `bux doc` shipped | -| **M14** | 11.5 | โณ | Native x86-64 backend (no C transpiler) | -| **M15** | 8.7 | โณ | `@[Release]` mode โ€” zero-cost abstractions; C-speed benchmarks vs Nim/Crystal | +| **M11** | 11 | โœ… | **Selfhost loop**: `buxc2` compiles itself โ†’ binary-identical `buxc3` | +| **M12** | 11.3 | โœ… | `@[Checked]` borrow checker works on real code | +| **M13** | 11.4 | โœ… | `@[Release]` zero-cost mode; Rust-style error snippets | +| **M14** | 8.3 | โœ… | **Green threads** โ€” M:N scheduler with channels | +| **M15** | 11.5 | โณ | Native x86-64 backend (no C transpiler) | +| **M16** | 11.4 | โณ | `bux test`, `bux fmt`, `bux doc` shipped | --- diff --git a/README.md b/README.md index c07affd..c4a0aaf 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ![Bux Language](bux-lang-01.jpeg) -> **Status:** v0.4.0 โ€” Bootstrap compiler (`buxc`, Nim) and self-hosted compiler (`buxc2`, Bux) both compile `.bux` โ†’ C โ†’ native binary. -> **Selfhost loop:** `buxc2` can compile itself โ€” deterministic C codegen verified. -> **LIR backend** produces clean 3-address C code. All 26 examples pass. -> **Gradual Ownership:** `@[Checked]` borrow checker, `borrow &mut` expressions, `@[Shared]` attribute. -> **Apps tested:** compiler successfully parses all 3 real-world apps (`apps/boko-framework`, `apps/jwt-pitbul`, `apps/nexus`) โ€” no hangs, no crashes. +> **Status:** v0.5.0 โ€” Bootstrap compiler (`buxc`, Nim) and self-hosted compiler (`buxc2`, Bux) both compile `.bux` โ†’ C โ†’ native binary. +> **Selfhost loop:** `buxc2` compiles itself โ†’ binary-identical `buxc3` โœ… Deterministic C codegen + ELF verified. +> **Gradual Ownership:** `@[Checked]` borrow checker, `@[Release]` zero-cost mode, `borrow &mut` expressions. +> **Green Threads:** M:N scheduler with channels (Go-style goroutines without GC). +> **All 26 examples pass.** Compiler successfully parses all 3 real-world apps (`apps/boko-framework`, `apps/jwt-pitbul`, `apps/nexus`). Bux is a fast, compiled, strongly-typed systems programming language. Features a C backend for native code generation, raw multi-line strings, gradual ownership (opt-in borrow checking), async/await, generics, algebraic enums, and a package manager. @@ -25,6 +25,9 @@ cd hello # Build and run bux run +# Build optimized release binary +bux build --release + # Cross-compile for ARM Linux (requires clang) bux build --target aarch64-linux-gnu ``` @@ -134,7 +137,7 @@ func Main() -> int { ### Channels (Producer/Consumer) ```bux import Std::Io::{PrintLine, PrintInt}; -import Std::Task::{Task_Join, TaskHandle}; +import Std::Task::{Task_Wait, TaskHandle}; import Std::Channel::{Channel, Channel_New, Channel_SendInt, Channel_RecvInt, Channel_Close}; func Producer(chPtr: *Channel) { @@ -164,8 +167,8 @@ func Main() -> int { let ch: Channel = Channel_New(3); let p: *void = spawn Producer(&ch); let c: *void = spawn Consumer(&ch); - Task_Join(TaskHandle { handle: p }); - Task_Join(TaskHandle { handle: c }); + Task_Wait(TaskHandle { handle: p }); + Task_Wait(TaskHandle { handle: c }); return 0; } ``` @@ -198,7 +201,9 @@ func Main() -> int { | **Standard Library** | `Io`, `Array`, `String`, `Map`, `Fs`, `Mem`, `Set`, `Path`, `Math`, `Task`, `Channel`, `Sync`, `Os`, `Time`, `Process` | | **Backend** | LIR โ†’ C transpiler (clean 3-address code, then gcc/clang) | | **Strings** | Raw multi-line backtick strings (`...`), C-string interop | -| **Gradual Ownership** | `@[Checked]` + `@[Shared]` + `borrow &mut` / `borrow &` expressions | +| **Gradual Ownership** | `@[Checked]` + `@[Release]` + `@[Shared]` + `borrow &mut` / `borrow &` | +| **Drop Trait** | Auto-drop for `@[Drop]` types (Array, Map, user-defined structs) | +| **Green Threads** | M:N scheduler (ucontext + SIGVTALRM), work-stealing queues | | **Async/Await** | `async func`, `spawn`, `.await` with stackful coroutines | | **Concurrency** | `Task`/`Channel`/`Sync` (pthread-based), `bux_async_yield`/`spawn` | | **CTFE** | `const func` โ€” compile-time function execution | @@ -213,24 +218,38 @@ func Main() -> int { ``` bux/ -โ”œโ”€โ”€ compiler/ # Compiler source code -โ”‚ โ”œโ”€โ”€ bootstrap/ # Bootstrap compiler (Nim) -โ”‚ โ”œโ”€โ”€ selfhost/ # Self-hosting compiler source (Bux) -โ”‚ โ””โ”€โ”€ tests/ # Compiler unit tests (Nim) -โ”œโ”€โ”€ library/ # Standard library -โ”‚ โ”œโ”€โ”€ std/ # Standard library modules (.bux) -โ”‚ โ”‚ โ”œโ”€โ”€ Io.bux, String.bux, Array.bux, Map.bux -โ”‚ โ”‚ โ”œโ”€โ”€ Fs.bux, Mem.bux, Set.bux -โ”‚ โ”‚ โ”œโ”€โ”€ Path.bux, Math.bux -โ”‚ โ”‚ โ””โ”€โ”€ Task.bux, Channel.bux -โ”‚ โ””โ”€โ”€ runtime/ # C runtime files (runtime.c, io.c) -โ”œโ”€โ”€ tests/ # Language integration tests +โ”œโ”€โ”€ src/ # ๐ŸŽฏ Self-hosting compiler source (Bux) +โ”‚ โ”œโ”€โ”€ main.bux # Entry point +โ”‚ โ”œโ”€โ”€ lexer.bux # Tokenizer +โ”‚ โ”œโ”€โ”€ parser.bux # Pratt parser +โ”‚ โ”œโ”€โ”€ ast.bux # AST node types +โ”‚ โ”œโ”€โ”€ sema.bux # Type checker +โ”‚ โ”œโ”€โ”€ hir_lower.bux # AST โ†’ HIR lowering +โ”‚ โ”œโ”€โ”€ c_backend.bux # HIR โ†’ C code generator +โ”‚ โ””โ”€โ”€ cli.bux # CLI driver +โ”œโ”€โ”€ bootstrap/ # ๐Ÿ”ง Bootstrap compiler (Nim) +โ”‚ โ”œโ”€โ”€ main.nim # Entry point +โ”‚ โ”œโ”€โ”€ cli.nim # CLI commands + build driver +โ”‚ โ””โ”€โ”€ ... # (mirrors src/ structure) +โ”œโ”€โ”€ lib/ # ๐Ÿ“ฆ Standard library (23 modules) +โ”‚ โ”œโ”€โ”€ Io.bux # Print, ReadFile, WriteFile +โ”‚ โ”œโ”€โ”€ String.bux # Full string API +โ”‚ โ”œโ”€โ”€ Array.bux # Generic Array +โ”‚ โ”œโ”€โ”€ Map.bux # Generic Map + StringMap +โ”‚ โ”œโ”€โ”€ Set.bux # Generic Set +โ”‚ โ”œโ”€โ”€ Task.bux # Green threads (spawn/await) +โ”‚ โ”œโ”€โ”€ Channel.bux # Producer/consumer channels +โ”‚ โ”œโ”€โ”€ Drop.bux # Drop trait interface +โ”‚ โ””โ”€โ”€ ... # Math, Fs, Path, Sync, Result, ... +โ”œโ”€โ”€ rt/ # โš™๏ธ C runtime +โ”‚ โ”œโ”€โ”€ runtime.c # Memory, scheduler, channels +โ”‚ โ””โ”€โ”€ io.c # File I/O wrappers +โ”œโ”€โ”€ tests/ # ๐Ÿงช Unit tests (Nim) โ”œโ”€โ”€ examples/ # Example programs -โ”œโ”€โ”€ tools/ # Additional tooling +โ”œโ”€โ”€ apps/ # Real-world applications โ”œโ”€โ”€ docs/ # Documentation -โ”œโ”€โ”€ buxs/ # Windows-compatible project root โ”œโ”€โ”€ README.md -โ”œโ”€โ”€ PLAN.md # Roadmap to self-hosting +โ”œโ”€โ”€ PLAN.md # Roadmap to v1.0.0 โ””โ”€โ”€ Makefile ``` @@ -251,6 +270,9 @@ make test # Run example programs make test-examples +# Verify selfhost binary parity (buxc2 โ†’ buxc3, identical) +make selfhost-loop + # Clean build artifacts make clean ```