|
| 1 | +# ProXPL Architecture Review |
| 2 | + |
| 3 | +Date: 2025-12-13 |
| 4 | + |
| 5 | +Overview |
| 6 | +-------- |
| 7 | +This document provides a high-level review of the ProXPL repository and architectural recommendations focused on modernizing, modularizing, and preparing the codebase for a production-grade VM and ecosystem. |
| 8 | + |
| 9 | +Current Layout |
| 10 | +-------------- |
| 11 | +- Top-level: `src/` contains the primary C implementation (lexer, parser, runtime, stdlib). |
| 12 | +- Public headers: `include/` exposes the VM and compiler APIs. |
| 13 | +- Tests: `tests/` covers bytecode and scanner tests. |
| 14 | +- Docs: `docs/` and `ARCHITECTURE.md` contain comprehensive design and language details. |
| 15 | + |
| 16 | +Key Observations |
| 17 | +---------------- |
| 18 | +- The code is separated into front-end (lexer/parser/type checker) and runtime (compiler, vm, chunk, intrinsics), which is a good foundation. |
| 19 | +- VM implementation is a working stack-based interpreter with bytecode and a simple chunk system; opcode definitions are centralized in `include/bytecode.h`. |
| 20 | +- There are separate `src/runtime` and `src/vm` directories; unify or clearly separate their responsibilities (runtime = primtiive runtime helpers, vm = dispatch & optimizations). |
| 21 | +- Missing/partial features: GC, IR, optimizer, JIT, module system, FFI, concurrency, standard library modules, tooling. |
| 22 | + |
| 23 | +Risks & Architectural Trade-offs |
| 24 | +-------------------------------- |
| 25 | +- Monolithic vs Modular: The current structure scales slowly (many top-level sources with cross-cutting includes). A clearer modular split (frontend/compiler/vm/runtime/stdlib/tools) will improve maintainability. |
| 26 | +- Versioning & ABI: As this project evolves, design public stable headers and internal headers; add `include/proxpl_api.h` that documents stable APIs. |
| 27 | +- GC/Heap: The current memory model is simple; target runtime should implement a generational GC with write barriers for performance and correctness in concurrency. |
| 28 | + |
| 29 | +Recommended Modular Structure |
| 30 | +----------------------------- |
| 31 | +- `frontend/` — lexer, parser, type-checker, AST, semantic analysis. |
| 32 | +- `compiler/` — IR, optimizations, bytecode emitter, linking. |
| 33 | +- `vm/` — bytecode format, bytecode interpreter, debugger hooks. |
| 34 | +- `runtime/` — memory management, GC, object model, compact object representation, GC safety wrappers. |
| 35 | +- `stdlib/` — native modules and bindings. |
| 36 | +- `tools/` — bench, build scripts, LSP, REPL utilities. |
| 37 | +- `ffi/` — C/Python bridge, FFI design and wrappers. |
| 38 | + |
| 39 | +Short-term Action Items (Phase 0) |
| 40 | +-------------------------------- |
| 41 | +1. Add a `TICKET-001: ir/opcodes.md` spec from `include/bytecode.h` and commit as canonical spec. |
| 42 | +2. Add `include/proxpl_api.h` and define the public stable API for VM and runtime. |
| 43 | +3. Create `scripts/` with `build_unix.sh` and `build_windows.ps1` that use CMake for cross-platform builds; add `CI` workflows to GitHub Actions. |
| 44 | +4. Move test harness to `tests/` and provide a `tests/CMakeLists.txt` to allow running tests with `ctest`. |
| 45 | +5. Add a `tools/bench` harness that executes core micro-benchmarks and produces a simple JSON report. |
| 46 | + |
| 47 | +Longer-term Priorities |
| 48 | +---------------------- |
| 49 | +- Implement generational GC with write barriers and a memory profiler. |
| 50 | +- Implement the IR and an optimizer pipeline with canonical IR passes (constant folding, DCE, inlining, escape analysis). |
| 51 | +- Add a JIT backend (start with a simple tracing JIT prototype or LLVM). Provide hooks in the VM for hot-trace extraction. |
| 52 | +- Add concurrency primitives: coroutines, channels, and threads backed by a scheduler. |
| 53 | +- Implement FFI for C and Python (MLVM-style embedding) with security hardening. |
| 54 | +- Ship an LSP server + VSCode extension with DAP instrumentation for the VM. |
| 55 | + |
| 56 | +Acceptance Criteria / Metrics |
| 57 | +--------------------------- |
| 58 | +- The repo should build via CMake on Linux/macOS/Windows using standard toolchains (GCC/Clang/MSVC). |
| 59 | +- The VM should provide consistent API across versions; header stability maintained via `include/proxpl_api.h`. |
| 60 | +- Micro-bench suite should show a reproducible baseline for CPU-bound and IO-bound tests. |
| 61 | + |
| 62 | +Next Steps I'm Prepared To Implement |
| 63 | +----------------------------------- |
| 64 | +- Add `ir/opcodes.md` and a clean, canonical opcode spec. |
| 65 | +- Add CMake test configuration and a sample GitHub Actions workflow. |
| 66 | +- Add `scripts/build_*.sh/.ps1` build helpers and a `tools/bench` harness. |
0 commit comments