The compiler

How the implementation developed, how it is organized and what a future bootstrap would require.

From a Python parser to C++.

The first experiment used a Python parser. The next step kept parsing in Python and emitted C++, which was then compiled. Removing Python from that path led to the current compiler written in C++. That is the project's development sequence; the current compiler is not self-hosted.

Today the C++ implementation separates source parsing, module and import resolution, semantic analysis, lowering, target code generation and runtime support. Native lowering is split into translation units for expressions, calls, control flow, values and retained scenes. WebAssembly has separate lowering and emitter modules; native targets have their own machine-code backends. The VKF standard-library sources remain a distinct layer. Browser JavaScript owns loading, worker lifetime and presentation while the WebAssembly compiler compiles VKF.

That separation also supports incremental builds. A changed translation unit can be rebuilt while unchanged objects are reused only when their source, headers, compiler flags and target identities match. Native and WebAssembly dependencies are tracked separately; changing a binding or shared header can invalidate more than one module.

Optimizations already in the selected compiler

Demand-driven lowering follows used definitions and preserves required captures and module dependencies. Proved closed record values can be embedded in counted lists instead of repeatedly boxed. Static index and fixed-extent producer analysis retain shape and coordinate information. Compiler-side semantic demand and retained optimization records bind reuse to source and artifact identities, rather than treating a cached result as universally valid.

The selected browser compiler also uses a size-conscious C++ build and WebAssembly local simplification and coalescing. These are implementation choices, not a measured speedup claim. Newer source-only reflection and erased-raise work is pending qualification and is not described here as deployed behavior. Selected-source evidence and module map.

Bootstrapping plan

  1. Keep a trusted seed. Pin the current C++ compiler, paired library, build inputs and target ABI. Preserve its diagnostics and executable reference behavior.
  2. Define a small VKF compiler subset. Start with the values, strings, arrays, scopes, functions, records and control flow needed for a lexer and parser. Record unsupported language forms explicitly.
  3. Move the front end in stages. Write the lexer, parser, module resolver and semantic passes in that subset. Compare their syntax trees, diagnostics, imports and lowered representation against the C++ seed on real programs.
  4. Add a backend and its runtime boundary. Target one documented representation first, preserve calling conventions and data layouts, then build the necessary library and compiler artifacts. Keep other backends on the seed until they pass equivalent checks.
  5. Close the bootstrap loop. Use the seed to compile the VKF compiler, then use that compiler to rebuild itself. Compare successive artifacts or a defined canonical representation, run differential correctness tests, and reproduce the build from pinned inputs before making any self-hosting claim.

These stages are a plan. A source directory or an experimental VKF component alone does not establish a self-hosted compiler.