DriftScript
Documentation

Rationale

Why std and drift do not share a prefix

One line in a consumer file, and what it costs to move later.

Why do std and drift not share a prefix?

Because the prefix is the one place a reader can see, without leaving the line, whether they are looking at something that works in every host or something this engine happens to provide. That distinction is the language's whole architecture, and burying it in build configuration would make it invisible in the only artefact anybody reads.

It decides what a file can promise

A program built only from std/* runs anywhere DriftScript runs, and that is checkable rather than aspirational. Everything under std is pure, and it is pure because of what it is: a clock, a scene and a world all belong to a host, so a library function that read one would belong under that host prefix.

// The two prefixes, in one file.
//
// `std/math` is the language's own and is pure, so it links in any host. `drift/scene` is this
// engine's, and it carries the effect of reaching a scene. The prefix in the import is what tells
// you which of the two you are looking at.
//
// `Node` is not a language type either. It arrives with the capability, from whatever the host's
// scene is made of, which is why a consumer with no renderer still has a language.

import { clamp } from "std/math"
import { setRotation } from "drift/scene"

data Spin {
    speed: f32 = 45deg
}

fn turn(spin: Spin, node: Node, dt: f32) {
    let step = math.clamp(spin.speed * dt, 0, 90deg)
    scene.setRotation(node, 0, 1, 0, step)
}

Why it was worth changing late

The two shared a prefix in the original design. The split happened when the language became something that might leave this repository, and it was done then because it is cheap in a consumer's source file and expensive in everybody's.

What it costs

Two things to explain instead of one, and a second namespace a newcomer has to place before they can read a file. It also means a host renaming its prefix breaks every consumer file, where build configuration could have absorbed it.