Ahead-of-time compilation (vibelang aot, experimental)
vibelang aot compiles a whole .vibe program, its entry and the local .vibe and .ts modules it imports, into one standalone Bun executable that does not run Effect's fiber runtime. Typed errors become a result slot instead of a Cause, a service read becomes a field load, scoped and acquireRelease become try/finally, and a try.all or for concurrent over a Sendable kernel runs on a pool of Worker threads.
The command is experimental. It is separate from vibelang -p .: a project that never calls vibelang aot compiles exactly as before, and vibelang-runtime does not import its runtime. A program that uses a form AOT's checks recognize as unlowered fails with a diagnostic and writes no output. The checks catch generated code that does not parse or reads a name it never defines, and declarations that shadow a lowered intrinsic. They cannot see a form the emitter translates into valid but different TypeScript; the differential oracle, the fuzz targets and the corpus below are the guard against that, so use AOT on the forms the table lists. -o never overwrites a source the program was loaded from: AOT refuses a destination that resolves to a source, and writes every output to a new file beside its destination and renames it into place, so it never writes through a symlink or into a hard-linked file.
vibelang aot app.vibe -o app # standalone executable ./app
vibelang aot app.vibe --emit-only # write app.aot.ts (and app.aot.worker.ts) instead
vibelang aot app.vibe --report # also print the analysis: tiers, services, kernelsWith a released Bun, vibelang aot builds with bun build --compile, and the Worker module is bundled as a second entry point. With a Bun AOT build that has the bun compile subcommand (pass it with --bun or BUN_AOT_BIN), it builds with bun compile --trim, and --explain passes through. AOT detects that subcommand by running bun compile --help in an empty temporary directory, so a project script named compile never runs. --threads N sets the Worker pool size (default 8; 1 disables the pool). npm imports, such as effect for the EffectBridge, resolve from the node_modules of the entry's project.
Supported subset
Each row names the test that holds it. "Differential" means the differential oracle runs the same program under Effect 4 and under AOT and compares results, logs and exits.
| Form | Status | Evidence |
|---|---|---|
effect function, try, throw of a declared error, catch, match on error tags | Compiles | Differential (nested-catches, match-*, catch-recovers-typed-failure) |
Evaluation order of target op= try f() and of the fields of throw new E({ … }); default and rest parameters of nested arrows | Compiles | Differential fuzz FuzzAOTReviewShapes (every target, operator, field order and arrow shape), TestReviewAssignmentEvaluatesTargetFirst, TestReviewUnboxedErrorFieldsKeepSourceOrder, TestReviewNestedArrowKeepsDefaultAndRestParams |
is pattern with a binding in an if condition | Compiles | TestReviewIsPatternInIfCompiles (not differential; other is homes are not verified) |
service, Layer.succeed, Layer.merge, provide blocks, nested overrides | Compiles | Differential (merged-services), TestNestedProvideOverride |
scoped, acquireRelease (LIFO release, finalizer failures), uninterruptible | Compiles | Differential (scoped-*, second-acquire-failure), TestScopedLIFOCleanupAndMasks |
| Deep and async recursion of effect functions | Compiles | Differential (recursion-*), TestDeepRecursionTrampoline |
try.all and for concurrent over a Sendable kernel (numbers, booleans, numeric data/schema) | Compiles to the Worker pool | Differential (sendable-parallel), TestSendableStructKernelRunsOnWorkerPool, benchmark B5 |
try.all, for concurrent over a kernel that is not Sendable | Compiles, runs on the calling thread | TestNonSendableClosureFallsBackToSingleThread |
fork, fork.scoped, fork.detached, join, try.race, try.any, try.allSettled | Compiles | TestForkJoinSuccessAndTypedError, TestTryRaceCancelsLoser, TestTryAnyAndAllSettled (not differential) |
data records and variants, match on their tags in plain functions | Compiles | TestDataRecordAndVariantMatch (not differential) |
Effect 4 values from import … from "effect" run with try | Compiles through the EffectBridge | Differential (catch-preserves-defect, -interrupt, -compound-cause) |
Local .vibe and .ts imports | Compiles into one module | TestAOTE2EMultiModuleAndFixtures/multi-mod |
runSync and runPromise entry calls | Compiles | Differential (every scenario settles through them) |
.vibe import of @effect/* or vibelang-runtime | Diagnostic AOT001 | TestVibeImportOfEffectPlatformIsRejected |
Effect modules used as values in .vibe (Console, Schema, Equal, …) | Diagnostic AOT003 | TestUnloweredEffectModuleIsLocatedInSource |
effect arrows and methods in object literals, effect methods in classes, effect function* producers, pipe % placeholders, effectful defaults in a catch handler's destructuring | Diagnostic AOT002 | TestEachUnloweredFormIsReported (one program per form) |
Generic data declarations | Diagnostic AOT003 | TestCorpusGapsBecomeDiagnostics/data-declaration |
A declaration or import named like a name the backends lower by spelling (succeed, fail, sync, restore, race, provide, Effect, …), in a program that calls that name; an import from effect binds the intrinsic only under its own name (import { Effect } from "effect", import { succeed } from "effect/Effect") | Diagnostic AOT004 | TestShadowedIntrinsicIsReported, TestAliasedEffectImportShadows, TestLoweredIntrinsicsCoverEveryMatchedName (reads the emitters' sources), fuzz FuzzAOTShadowedIntrinsic |
| Import cycles, unresolved local imports, one top-level name declared in two modules | Error before analysis | TestAOTE2ECorpusCoverage (module graph) |
Over the acceptance corpus (TestAOTE2ECorpusCoverage, 1,051 cases with a main.vibe and an expected stdout), AOT compiles 625 cases and reports a diagnostic or module-graph error for 426. Of the compiled cases, the 5 whose expected stdout AOT can produce on its own match exactly; the other 620 compile cleanly but have no stdout oracle that runs without Effect, so they are checked statically only. The 625 compiled cases are pinned in internal/vibelangaot/testdata/aot-corpus-emitted.txt: the test fails when one of them stops compiling.
Diagnostics
| Code | Meaning |
|---|---|
AOT001 | A .vibe file imports an Effect platform package or the VibeLang runtime. AOT lowers neither their runners nor their services. |
AOT002 | The generated TypeScript does not parse: AOT has no lowering for a VibeLang form and copied it. |
AOT003 | The generated program reads a name it never defines, usually an Effect module such as Console. The diagnostic points at the first identifier with that name in the .vibe source, skipping comments and strings, when it finds one. |
AOT004 | A declaration or aliased import shadows a prelude name the backends lower as an Effect intrinsic, so a call to it would compile to the intrinsic. Rename the declaration. |
AOT005 | --target=native only: the native preview has no faithful C lowering for this statement, expression or operator. The Bun target may still compile the program. |
Compile such a program with vibelang instead.
Native target (preview)
--target=native --preview-native compiles to C and builds with clang, or cc when clang is missing. It first runs the same checks as the Bun target, then refuses with AOT005 every statement, expression and operator it has no faithful lowering for, instead of emitting C for it. It represents numbers as 64-bit integers, with doubles only where a value comes from performance.now(), a fractional literal, -0 or arithmetic on one; strings as immutable UTF-8; and booleans. Where a value leaves what that representation holds exactly, the program stops with exit status 70 and a message naming the value, instead of printing a different one.
| Form | Native behavior | Evidence |
|---|---|---|
if, for with one integer counter, while, break, continue, return, throw, catch and match on error tags, services, scoped with acquireRelease of { handle, active } | Compiles; operands and arguments run left to right | TestNativeEmitAndExecuteE2E, fuzz FuzzAOTNativeLoops and FuzzAOTNativeOperandOrder (against Bun), bench_suite.vibe (same checksums as Effect 4) |
Conditions of if, while, for and ?: | Compiles; a boolean, number or string is tested as JavaScript tests it ("", 0 and NaN are false); ?: with an integer and a double branch yields a double | Fuzz FuzzAOTNativeTruthiness (against Bun) |
Integer +, -, *, +=, -=, *=, unary - | Compiles; a result beyond 2^53 in magnitude, or a negative zero, stops the program with exit status 70 | Fuzz FuzzAOTNativeIntArithmetic (against Bun) |
Integer / and % | Compiles; a result that is not an integer, or is negative zero, stops the program with exit status 70; (a / b) | 0 truncates as JavaScript does | TestNativeValuesMatchJavaScript |
Calls to plain and effect functions, returns, error and data fields | Compiles; a double passed or stored where a number is declared converts exactly or stops the program with exit status 70; a program function named like a host call (Number) is called, not the host | Fuzz FuzzAOTNativeArgCoercion, FuzzAOTNativeHostShadow (against Bun) |
Indexing a try.all result | Compiles for an integer index; one outside the result stops the program with exit status 70 | Fuzz FuzzAOTNativeIndex (under AddressSanitizer, against Bun) |
String + and templates, .length and .slice in UTF-16 code units, startsWith, ===/!== on strings | Compiles; strings are allocated on the heap and never freed; a slice that would split a surrogate pair stops the program with exit status 70 | Fuzz FuzzAOTNativeTemplates (under AddressSanitizer), FuzzAOTNativeStringOps (against Bun) |
console.log of numbers, doubles, booleans and strings | Compiles; doubles print with JavaScript's digits and notation, a negative zero as -0 | Fuzz FuzzAOTNativeDoubles (against Bun) |
Number(s) | Compiles; a string that does not hold an integer of at most 2^53 in magnitude stops the program with exit status 70 | Fuzz FuzzAOTNativeNumber (against Bun) |
do, for…of, switch, try statements, arrays other than a try.all result, an integer literal index outside a try.all result or an index that is not an integer, objects, Math, string ordering, &&/|| on non-booleans, ?: with branches of different kinds other than integer and double, a string holding a NUL character, an error not built from one object literal giving every field, default and rest parameters, and a try or catch in a loop condition, for incrementor, conditional branch or right side of &&/|| (a template there compiles) | Diagnostic AOT005 | TestNativeRefusesUnloweredForms, TestNativeReview3Refuses, fuzz FuzzAOTNativeNULStrings, FuzzAOTNativeIndex |
There is no differential oracle for whole programs on this target, so it needs the explicit flag.
Performance
Median time per operation of 3 runs of experiments/bench/aot/bench_suite.vibe (AOT) and its Effect 4.1.6 twin effect-baseline.ts, measured on 2026-12-01 (UTC, the container's clock) after the native preview's checked arithmetic and exact conversions with Bun 1.4.4 (released; no bun compile, so no --trim) on a 4-core x86_64 Linux container, 8 Worker threads, cc (gcc) for the native preview. effect-jit is bun run; effect-compiled is bun build --compile. All four runners printed identical samples and checksums for every benchmark, and the script fails if they do not.
| Benchmark | effect-jit | effect-compiled | aot-bun | aot-native | aot-bun vs effect-jit | aot-bun vs effect-compiled |
|---|---|---|---|---|---|---|
| B1b req happy (200k) | 3.5 µs | 2.9 µs | 129.2 ns | 179.6 ns | 27.3x | 22.5x |
| B1c req error 404 (200k) | 4.1 µs | 3.7 µs | 43.6 ns | 28.0 ns | 94.0x | 84.2x |
| B1d req error 401 (200k) | 3.2 µs | 3.1 µs | 21.0 ns | 6.4 ns | 154.9x | 147.8x |
| B2 deepChain(16..23 200k) | 13.6 µs | 13.3 µs | 105.5 ns | 13.3 ns | 128.6x | 126.4x |
| B3 errorLoop(96..103 50k) | 152.4 µs | 142.0 µs | 231.2 ns | 84.9 ns | 659.2x | 614.5x |
| B4 scopedOp (200k) | 6.4 µs | 5.8 µs | 15.9 ns | 2.1 ns | 404.4x | 366.8x |
| B5a parallelCpu(8x50k) | 3.91 ms | 3.66 ms | 1.65 ms | 2.21 ms | 2.4x | 2.2x |
| B5b parallelCpu(8x250k) | 17.04 ms | 17.93 ms | 6.00 ms | 9.86 ms | 2.8x | 3.0x |
Reproduce from the repository root after building typescript/built/local/tsc and installing experiments/node_modules:
bash experiments/bench/aot/run.sh 3The single-thread rows measure removing the fiber runtime: typed failures, service reads and scopes cost nanoseconds instead of microseconds. The B5 rows measure the Worker pool on 4 cores. Numbers vary with the machine; the speedup columns are the claim, not the absolute times.
How it is verified
| Suite | Command (from typescript/tsc unless noted) |
|---|---|
| Analyzer, emitters, checks, CLI, corpus | go test ./internal/vibelangaot/... |
| Differential oracle and fuzz seeds (Effect 4 or Bun versus AOT, output aliasing, shadowed intrinsics, native values) | VIBELANG_FUZZ_REQUIRE=1 EFFECT_NODE_MODULES=$PWD/../../experiments/node_modules go test -short ./internal/vibelangfuzz/ -run AOT |
| Runtime package | bun test in packages/aot-runtime |
| Benchmarks | bash experiments/bench/aot/run.sh from the repository root |
The Z3 and Dafny proofs in internal/vibelangaot/proofs run when z3 and dafny are on PATH; without them the tests check the proof files' structure only. On 2026-12-01 (UTC) the Z3 obligations and their mutation checks passed again with Z3 4.13.4 (PATH=<z3>/bin:$PATH go test ./internal/vibelangaot/proofs/); Dafny was not available, so the Dafny proofs were checked structurally only. The typed-access and --trim gates (TestAOTExplainAndTrimGate) need a Bun AOT build and skip on a released Bun.