Q+ 快速上手 / Getting Started(1.9.0-dev / spec v4.40)
English. Q+ is a statically typed systems/application language with a self-hosted compiler (
qboot), bytecode VM (bqvm) and an ELF AOT backend (cgtest_aot, Linux x86-64). This tutorial takes you from build to your first VM/AOT program, tests and next steps. Commands/outputs were run on the 1.9.0-dev candidate (v190_rc1) on Linux x86-64.1.9.0-devis a release candidate (NOT PUBLISHED), not a final release.中文:Q+ 是静态类型系统/应用语言,自带编译器
qboot、字节码 VMbqvm与 ELF AOT 后端cgtest_aot(仅 Linux x86-64)。本教程覆盖构建 → 第一个程序 → VM/AOT 运行 → 测试 → FAQ/下一步;命令与输出在 1.9.0-dev 候选(v190_rc1)Linux x86-64 实测。
0. 前置条件(Prerequisites)
- Linux x86-64(AOT 仅此平台;Windows/ARM64 无 AOT);Python 3.11+、bash、C 工具链;
- 无需第三方 Python 包;1.9.0-dev 为发布候选(NOT PUBLISHED)。
1. 构建(Build)
bash tools/build.sh # ~1–2 分钟
实测输出(尾部):
Phase 3: CodeGen
Constants: 257 Code bytes: 76365
[Q+ build] artifacts in .../build
b526b807... build/bqvm
bd0dec4b... build/bqvm_small
7248ce0d... build/qboot.qbc
1dc2d240... build/cgtest.qbc
cbd42172... build/cgtest_aot
锚点应与 BUILDING 的 5 锚点一致;
bootstrap/qboot.qbc与bootstrap/cgtest_aot为固定点。
2. 第一个程序(First program)
use std.io;
fn main() -> i32 {
print("Hello, Q+!\n")
return 0
}
build/bqvm --timeout-ms 0 build/qboot.qbc hello.q -o hello.qbc
# Phase 3: CodeGen / Constants: 19 Code bytes: 796
3. VM 运行(Run on the VM)
build/bqvm hello.qbc
# Hello, Q+!
4. AOT ELF 运行(AOT)
AOT 工具用位置参数 cgtest_aot <in.qbc> <out.elf>(不是 -o),且不写可执行位:
build/cgtest_aot hello.qbc hello.elf # EMIT_OK code=54587 elf=57392
chmod +x hello.elf
./hello.elf # Hello, Q+!
AOT 未支持能力(线程/async/FFI/std.fs/网络/未支持 sys)loud(rc=5/no ELF 或运行期 trap)。 AOT 网络可行性结论 B:本轮不交付、AOT 保持 loud(AOT-net feasibility)。
5. 测试(Test)
bash tools/test.sh # 通过时末行 QPLUS_LANGUAGE_TESTS_PASS
bash tools/test_qfmt.sh # qfmt 306 checks / 29 fixtures
6. 文档站与 Playground(Docs site & Playground)
cd site
python3 build_site.py --qplus-root .. # 78 页 / 155 checks(候选)
python3 ci/selftest.py # 155/155 PASS
python3 playground.py # http://127.0.0.1:8787/
Playground 是本地/内部演示,非沙箱/非公网安全边界;运行器限额不变 (安全边界)。
7. FAQ / 常见问题
Permission denied运行tools/build.sh→chmod +x tools/build.sh tools/test.sh;- AOT 运行无输出/找不到文件 → 用位置参数
cgtest_aot in.qbc out.elf并chmod +x out.elf; - AOT rc=5/无 ELF → 使用了 AOT 未支持能力(loud),改 VM 或查限制文档;
- 真网络 → 默认 loopback 仿真;
QPLUS_NET_REAL=1开真 loopback;非 loopback 需显式权限; 仍为 VM-only POC,非生产; - u64 字面量 → 1.9.0 支持十进制/hex/二进制 ≤2^64-1;负 u64 编译期 loud([TC15]);
- 版本 → 以
VERSION/spec 头部为准;站点为候选文档,非发布声明。
8. 下一步(Next steps)
- 语言:Language Guide (EN) · 语言规范 · 英文规范摘要;
- 平台/限制:BUILDING · FAQ · Portability;
- 网络 Phase4:docs/NET_IMPLEMENTATION_PHASE4;
- 工具链:qfmt · qpm 安装 · qpm 生产化 POC;
- Playground:部署与安全边界。
English walkthrough
Prerequisites: Linux x86-64, Python 3.11+, bash/C toolchain; 1.9.0-dev is a release candidate (NOT PUBLISHED).
bash tools/build.sh
cat > hello.q <<'EOF'
use std.io;
fn main() -> i32 {
print("Hello, Q+!\n")
return 0
}
EOF
build/bqvm --timeout-ms 0 build/qboot.qbc hello.q -o hello.qbc
build/bqvm hello.qbc # Hello, Q+!
build/cgtest_aot hello.qbc hello.elf # EMIT_OK code=54587 elf=57392
chmod +x hello.elf && ./hello.elf # Hello, Q+!
bash tools/test.sh # QPLUS_LANGUAGE_TESTS_PASS
Candidate anchors: bqvm b526b807…, bqvm_small bd0dec4b…, qboot 7248ce0d…, cgtest.qbc 1dc2d240…, cgtest_aot cbd42172…. See Language Guide, FAQ, SPEC_SUMMARY.en; network Phase4 is a VM-only loopback POC and AOT networking is conclusion B (not delivered, AOT loud).