Skip to content

Nift v4.13.0 — Runtime 2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 30 Nov 01:31
· 1 commit to main since this release

Nift v4.13.0 — Runtime 2.0

Nift v4.13.0 introduces Runtime 2.0, a new bytecode virtual machine for
Nift's scripting surface. Runtime 2.0 is the default engine for script files,
-e/-c/stdin programs, nift eval, and interactive sessions. Website
templates continue to use the established legacy renderer, so ordinary Nift
website builds keep their existing behaviour and output.

Nift remains a website generator and dependency-aware build layer. Runtime 2.0
improves the scripting engine; it does not change that product boundary.

What is new

  • A new default scripting engine. Runtime 2.0 compiles supported programs
    before execution. Constructs outside the supported subset are refused before
    any part of the program runs, with a source location where available (or the
    script/start line otherwise) and a clear route back to the legacy engine.
    There is no silent fallback.
  • Broad script coverage within the documented Runtime 2.0 subset. The
    release is exercised across functions and closures, modules and package
    imports, arrays, objects, collections and structs, reference and mutation
    semantics, diagnostics, host operations and handles, parallel tasks, and
    interactive sessions.
  • Package compatibility. The unchanged 12-module package regression suite
    passes with Runtime 2.0 as the default, with NIFT_VM=require, and with
    explicit legacy execution. The tested ecosystem includes integrations built
    with SQLite, curl, ImageMagick and Vips. This is a tested package subset, not
    a claim about every third-party package.
  • Safety and diagnostics. Runtime 2.0 keeps pre-execution refusal for
    unsupported operations, checks runtime types and mutation operations, detects
    reference cycles, manages typed resource handles, and reports failures with
    source locations where available.
  • Platform coverage. Release validation includes Linux, macOS, Windows and
    FreeBSD 14 amd64 qualification. Official binary archives are provided for
    Linux x86-64, macOS arm64, macOS x86-64 and Windows x86-64.

Compatibility and migration

Runtime 2.0 is intentionally conservative where the VM cannot yet preserve
legacy behaviour. Unsupported programs are refused before execution rather than
run with different semantics. Use NIFT_VM=0 to run the legacy interpreter.

The main migration points are:

  • File built-ins are qualified. In VM-run scripts and sessions, the seven
    file built-ins cat, cp, mv, rm, ls, mkdir and touch are called
    with the native:: qualifier, for example native::cp("a", "b"). An
    unqualified call with no user or module function of that name is refused
    before execution. NIFT_VM=0 keeps the legacy spelling.
  • Some legacy script forms still require the legacy engine. These include
    bare shell-command statements, stored or indirectly invoked async function
    values, the file forms of minify(), nested #! comments, general process
    execution outside the documented package scope, FFI, timers, project/template
    script APIs, dynamic imports, and legacy dynamic scope. The independent Nift
    regression suite is the legacy compatibility contract and includes many of
    these forms; validate legacy behaviour with NIFT_VM=0. See the Runtime 2.0
    known-limitations documentation for the complete list.
  • C ABI 1.4 adds Runtime 2.0 program APIs. nift_program_compile() and
    nift_program_run() expose the VM program lifecycle and result metadata.
    The change is additive: existing ABI 1.3 symbols, signatures and layouts remain
    source compatible.
  • Sorted collections have a defined mixed-domain diagnostic. Inserting both
    numeric and string keys into a sorted map, or both numeric and string members
    into a sorted set, now fails with sorted_map: incomparable keys or
    sorted_set: incomparable values. The reached insertion fails before the
    collection changes, including through aliases. Homogeneous numeric and string
    ordering is preserved.
  • Most runtime errors remain fatal. The existing error()/throw/catch
    model is unchanged, and ordinary runtime failures such as bad indexes and
    undefined callables remain fatal. Refused reference cycles and sort-receiver
    mutation are intentional catchable Errors (runtime.reference_cycle and
    runtime.sort_receiver_mutated).
  • Import-resolution errors stop before execution. When legacy also raises
    the import error, package and module resolution failures reject the program
    with legacy's text and position before any statements run. An import left
    unreached by a top-level return is rejected by the VM even where legacy
    exits without running it.
  • Some supported programs intentionally differ from legacy. Runtime 2.0
    uses shared-reference semantics for arrays, objects, collections and structs
    (arrays and objects are an intentional difference from legacy copies);
    const is binding-only; reverse() and sort() return the receiver; splice
    argument order and some assignment-family diagnostics are documented
    differences. Review docs/runtime-2/compatibility.md before migrating
    programs that depend on legacy copy or mutation behaviour.

The detailed compatibility contract and known limitations are in
docs/runtime-2/compatibility.md and docs/runtime-2/known-limitations.md.

Validation

Runtime 2.0 was validated on the exact release candidate across Linux, macOS,
Windows and FreeBSD 14 amd64. The release passes the Runtime 2.0 compatibility,
safety and package checks, including the 12-module package suite in VM-default,
VM-required and legacy modes. No new numerical performance claims are made in
this announcement; the website build path and template renderer are unchanged.