Stories: Foundations

See also: spec/foundations.md — the commitments this story explains.

The bet on captured intent

The fork is the oldest fork in language design: meet the machine where it is, or meet the programmer where they are. A low-level language like C makes the source a faithful transcript of machine steps — fast, but the intent is buried under bookkeeping. A high-level managed language, which is most of the rest, makes the source express intent — readable, but it pays for the altitude with a runtime that guesses at the mechanism the programmer elided. Both roads were on the table, and both were rejected: the low-level road because intent is recoverable only by reverse-engineering the bookkeeping, and that recovery is exactly the hard part of whole-program optimization; the managed road because it buys readability by handing the mechanism to a runtime that must be conservative, which is the performance cost we are trying to avoid in the first place.

Zane bets that this is a false choice if the source is forced to be unambiguous. The wager is that a program expressing intent cleanly leaves the compiler more freedom to choose the mechanism, not less, because nothing important was left implicit for a runtime to reconstruct. High level and fast are not opposed; they are both consequences of intent being captured well. The catch, and the reason this is a real bet rather than a slogan, is the word forced. The altitude only pays off if expression is unambiguous, and programmers do not write unambiguously on their own — so the rest of the foundations, and most of the language’s strictness, exist to make good expression mandatory. Captured intent is the goal; the strictness is the price of admission. The bet only holds for well-expressed programs, and the language makes you express well by force, which is a real ergonomic cost: more up-front rules to satisfy than either a permissive low-level or a permissive high-level language demands. The whole language is, in a sense, a standing test of whether that trade was worth it.

Everything has to earn its place

One deliberately strong claim behind Zane — and the sentence from which the rest of this design philosophy grew — is that everybody is stupid. Taken literally, that is obviously false: intelligence is not one objective quantity, and people are capable of extraordinary work. It is useful instead as a working assumption for design and problem solving: nobody is exempt from being wrong, overlooking an assumption, repeating a convention they never questioned, or solving yesterday’s problem long after its constraints have disappeared. Reputation, consensus, and precedent therefore do not substitute for an argument.

The rest of the design guidelines in this section are consequences of that one sentence. If nobody receives epistemic authority merely for having designed a feature before us, then existing languages are evidence to investigate, not templates to follow. If precedent cannot finish an argument, then every feature and restriction has to be justified from first principles. If our own reasoning is fallible too, then our claims should be made strong enough to falsify rather than hedged until they can survive any objection. And if “everybody” includes us, then Zane’s own past decisions receive exactly the same scrutiny as somebody else’s.

A feature appearing everywhere is evidence that many designers encountered some problem worth solving; it is not evidence that their abstraction is the right abstraction, that the original constraint still applies, or even that the feature was a good answer in the first place. “Other languages do this” can tell us where to investigate, but it cannot finish the investigation. We want to be able to follow a decision downward until it reaches a concrete reason: a safety property, a performance invariant, a semantic distinction, a readability requirement, or some other constraint we are actually willing to defend. If the chain bottoms out only in convention, the design is unfinished.

Language design is also a design question, not a science question. A scientist investigates facts about an object that already exists independently of the investigator. If astronomy establishes that a star was eight light-years away at some point in time, later work can cite that result because there is one underlying fact to recover; a correct measurement remains correct no matter who uses it. Language design has no corresponding object waiting to be discovered. The designer begins with a set of constraints and looks for the most elegant mechanism that satisfies them. Several mechanisms may be completely possible, internally consistent, and publishable while still being the wrong design for those constraints.

That distinction changes how we treat research papers. Research can show us the possible mechanisms and their consequences. It cannot settle the design we ought to build. A paper can give us a theorem, expose a technique, characterize a trade-off, or show that some mechanism is possible. All of those are useful evidence. A paper cannot make a design choice correct merely by having proposed it. Treating the literature as a catalogue of features to accumulate confuses research about programming languages with the act of designing one. A mechanism does not earn a place in Zane because it appeared in a paper, any more than it earns one because Rust, Haskell, or C++ already uses it. Papers are evidence to investigate too: we take the facts and techniques they establish, then return to Zane’s own constraints and justify the design from there.

This is why a previous language design can be perfectly implementable and still be false for our purposes. In science, two incompatible claims about the same measured fact cannot both be right. In design, two incompatible mechanisms may both work; the disagreement is over which one best satisfies the chosen constraints, which costs are acceptable, and which abstraction is most coherent with the rest of the system. There is therefore no contradiction in respecting the technical work behind an existing solution while rejecting the solution itself.

The same attitude shapes how we investigate. Zane deliberately makes strong claims because strong claims are easy to dismiss when they are wrong. “Pattern matching is unnecessary” invites a concrete program that cannot be expressed cleanly without it; “pattern matching has trade-offs” can survive almost anything and therefore teaches us very little. “This restriction is the minimum needed for safety” invites a safe counterexample after the restriction is loosened. A successful counterexample exposes a requirement we did not understand before, and the claim should then narrow, change, or disappear.

The abrasive phrasing of “everybody is stupid” is useful for the same reason. “Everyone can sometimes be mistaken” is nearly impossible to disagree with and therefore changes very little about how one behaves. The stronger sentence forces the useful posture: do not grant anyone, including yourself, exemption from having to justify their beliefs and their work. This is broader than language design; it is the general problem-solving habit that produced Zane’s design method.

The point is not contrarianism, and a strong claim receives no protection once it fails. The method only works if conclusions are held more weakly than the arguments supporting them. Zane’s own existing design gets no exemption: an old Zane decision is just another inherited decision once we return to it. Several parts of the language have already been removed, split, or rebuilt because their original justification stopped surviving scrutiny.

The goal is therefore not novelty. If reasoning from first principles leads back to a conventional design, that design has earned its place. If it leads to an unusual design, familiarity is not an argument against it. What matters is that we can state why a feature exists, which constraint requires it, what it costs, and which change would let us remove it.

The compile-time model: staged types

That bet rests on a decision about when the compiler does its work. Making types ordinary compile-time values, executed in an earlier stage, is the root that generics, the <>/() split, and compile-time arguments all grow from. The full argument — why staging beats a bolt-on generics sublanguage, and where the model currently overpromises, on type-level arithmetic and on constraints — is told once, in the generics story, rather than duplicated here. The short version of the cost is that the elegance of “a type is just a function you run” oversells how much falls out for free. Type identity for computed type expressions, and constraints on parameters, do not fall out of it; they are the hard parts the framing hides, and the generics story tracks them.

The surface grammar also needs to distinguish type names from value names. We enforced the intended PascalCase/camelCase convention because it simplifies parsing and removes possible ambiguities; making the distinction visible to readers is a useful side benefit. That is a practical syntax decision, separate from the staged type model. Its reasoning belongs in the lexical story.

Strictness is the performance model

The performance rules carry a larger cost than a naming convention. The framing to reject is that Zane has two separable properties — it is strict (single ownership, fixed layout, enforced effects, mandatory error handling) and it is fast — as if these were independent selling points that happen to coexist. They are not independent. The strictness is the cause of the speed. Every rule that forbids a convenience is the same rule that lets the compiler stop guessing: known ownership gives deterministic destruction with no collector, fixed layout gives direct access and cheap copies, known effects give safe automatic parallelism. It is the same trade Rust makes — you do not get speed from being expressive, you get it from the invariants the rules preserve, and the expressiveness is what those invariants buy back.

This is why the language forbids rather than discourages. A guarantee that holds only when the programmer is careful is a guarantee the compiler cannot build on; it would have to emit the conservative path anyway, for the cases where the programmer was not careful, so optionality forfeits the entire benefit. The rule has to be total to be worth anything. Strict-by-default with pervasive opt-out escape hatches fails for exactly that reason — each hatch reintroduces the conservative path the strictness was meant to eliminate (narrow, clearly-marked unsafe-style boundaries are a separate question; pervasive opt-out is what fails). Going permissive and leaving optimization to the compiler fails too, because without the invariants the compiler is reduced to proving them by analysis, which is undecidable in general and conservative in practice; better to have the language guarantee what the optimizer would otherwise have to prove.

This is the language’s steepest cost. Mandatory strictness brings a higher learning curve and more programs rejected that would have run fine — the price of forbidding a convenience is that you cannot use it even when it would have been safe in your particular case. We are betting that the floor it puts under performance and reasoning is worth the constructs it takes off the table. It is the most expensive bet in the language, and the bet most worth revisiting if the ergonomic cost proves too high in practice.

There is a quieter companion to this bet, and it points the other way. Strictness forbids conveniences to buy performance; but Zane also prizes simplicity and readability for their own sake, and where a simpler, more readable rule can be had without surrendering performance, it is preferred even over a more powerful one. Lifetimes are the clearest case. A maximally expressive system would track references with a lifetime vocabulary and borrow inference, the way Rust does, and accept more programs for it; Zane instead checks reference safety with nothing but lexical declaration scope — a rule a reader can run in their head, conservative by design, that gives up some safe programs but costs no performance, since deterministic destruction needs no collector and no annotations to enforce. That the readable rule and the fast language coincide there is not luck; it is the captured-intent wager again, that high level and fast are consequences of the same captured intent, this time spent on lifetimes rather than on the optimizer. The full working-out — why annotations were refused and how scope alone carries the weight — is the lifetimes story; it is a direct result of this principle, not a separate idea.

The verifiability symmetry, and the one gap in it

That preference rests on a claim worth making explicit, because it is the reason the readable rule and the checkable rule so rarely pull apart. The claim is a rough symmetry between two kinds of certainty. If the compiler has to do hard work to verify a property statically, a programmer reading the code almost certainly cannot quickly verify it either — the analysis is heavy precisely because the property is non-local, conditional, or flow-dependent, and a human eye cannot settle exactly those properties at a glance. The symmetry runs the other way too, and that direction is the useful direction: when a programmer can be 100% certain, just by reading, that a property holds, the compiler can almost always be made to verify that property mechanically — because the property obvious to a reader is obvious for being local and structural, and local structural facts are what a checker confirms cheaply. So a rule a human can verify by reading is not a concession to the human paid for at the compiler’s expense; it is a win for both at once. It is why Zane reaches, wherever it can, for rules of that shape — lexical scope being the running example: a reader confirms an owner outlives a ref by seeing one declaration nested inside another, and the compiler confirms it the very same way.

There is one place the two certainties come apart, and it is the place Zane works hardest to stay out of: flow-dependent reasoning. A compiler can hold every branch of a program in mind at once — at each point it tracks the full set of paths that could have reached it. A reader cannot; a reader follows the code roughly as it runs, one plausible path at a time, and leans on surface cues — names, reading order — for the rest. So the moment correctness depends on which branches ran, the compiler stays certain while the human is guessing. Rust’s borrow checker lives in exactly that territory. Take a conditional move:

let report = build_report();

if urgent {
    send(report);          // moved into `send` — but only on this branch
}

archive(report);           // ERROR: `report` may already have been moved

Read top to bottom the code presents a coherent story — build a report, send it if it is urgent, archive it — and a reader leaning on the method names, send and archive both sounding harmless, has no reason to doubt it. But send takes its argument by value, so the branch moves report away, and at archive the value is only maybe still there. The borrow checker considers both paths and rejects the program; the reader, having followed one, did not see it coming. The fact that settles correctness — does report survive to archive? — lives in the branch structure and the by-value signature, not in anything the names suggest, and it is exactly the kind of multi-path fact a compiler confirms easily and a human confirms badly. This is the symmetry’s first half in the wild: the compiler is doing work the reader cannot follow, so the two have stopped checking the same property — and a reader who fills the gap by trusting the names is trusting the one channel that carries no guarantee.

Zane declines to enter that territory at all. A value may be moved only in its declaration block, as straight-line code (the declaration-block rule), so a conditional move simply cannot be written. The effect is that the load-bearing fact is never flow-dependent: there is exactly one place report could be consumed, it is in plain sight, and the reader sees precisely what the compiler sees. The cost is real, and the lifetimes story owns it — programs that lean on conditional moves in Rust must be restructured in Zane — but the payoff is that the reader’s glance and the compiler’s proof are about the same artifact again. Where Rust buys expressiveness by letting the checker reason across control flow the reader cannot, Zane buys legibility by forbidding the cases where that reasoning would be needed.

A foundations doc, apart from its philosophy

One last decision is this file’s own existence. The cross-cutting “why” of the language could have lived in one essay, mixing the model with the argument for it. We split it instead: the model — staging, fixed layout, the strictness principle — is normative and lives in spec/foundations.md, because topic docs cite it as ground truth; the bets and costs, this file, are story material, because they are opinion, history, and honestly-stated downside. Folding both into a single philosophy.md would have mixed normative grounding that other docs must reference as fact with editorial argument that should be free to be revised and second-guessed — the exact what/why blend the spec/stories split exists to prevent. The price is that a reader after the big picture now has two files instead of one, mitigated by the cross-links: the spec doc states each commitment and points here for the argument. We accept the extra hop for the same reason the whole split exists — a definition and the debate behind it have different lifecycles and should not share a page.

Identity is opt-in: one axis for value and reference

For most of the language’s life there were two record kinds, struct and class, and they differed along what looked like several axes at once: value versus reference, immutable versus mutable, inline versus heap, alias-free versus alias-bearing. Treating them as two atomic kinds hid that these were not one distinction but a bundle, and an inconsistent one — a struct was a value and immutable and alias-free, a class a reference and mutable and alias-bearing, with no way to ask for one property without the others. The pressure that forced this open came from concurrency (the value-typed-mutation chapter records that half of the story): the concurrency safety rule needed alias-freedom, but the only alias-free kind of type was also immutable, so there was no mutable-yet-alias-free type to hand to a spawn.

Pulling the bundle apart, the axis that actually mattered turned out to be exactly one: does a type have identity? Everything else follows from it. An object with identity can be pointed at, so it can be aliased through &; can be shared, so it needs an anchor to survive moves; can recurse, because a self-reference is just a reference. An object without identity is a value: copied, alias-free, and — the load-bearing consequence — transitively alias-free, because it can hold nothing that has identity either. So we collapsed struct and class into one axis and one mark: a type is a value unless written #, which opts it into identity (foundations.md §7). struct/#struct and variant/#variant became the same body under two settings of one modifier, and the old class keyword dissolved into #struct.

The road not taken was to keep struct and class and simply add a third kind for the missing corner — a mutable-but-alias-free record, the role a dedicated group kind would have played. We built that idea out fully before rejecting it: it works, but it spends a whole new keyword and a new set of rules on a single cell of a table that, once you see the table, obviously wants to be filled by an orthogonal modifier rather than an nth kind. Making # a modifier that composes with any type — including #Int and #enum, reference cells over types that were never “kinds” at all — is both smaller and more general than any fixed roster of keywords could be. That generality is the point: the rule is “identity is a mark you add,” not “here are the four blessed shapes.”

This foundation costs a real shift in the meaning of the two familiar words. struct is no longer “the value record”; it is “the value product”, and it is now mutable in place, which surprises anyone who reads struct as C or Rust does. class is gone as a word, and a reference type is spelled #struct, which reads oddly until the axis clicks. We judged the one-time dissonance worth a type system whose whole shape is two independent questions — what shape? and does it carry identity? — instead of a short list of kinds that each silently answer both. The downstream documents (memory.md for the anchor half, concurrency.md for the safety half) are shorter for it, because each can now write “reference type” or “value type” with one precise meaning.

Restriction is information, and the test of a good one

The value side of that axis is transitively alias-free, and we adopted it for a specific, local reason: concurrency needed a mutable type that no two names could reach two ways. But a property adopted for one reason is not confined to that reason, and this one kept paying out in places we had not been looking. It is why there is no collector — with nothing aliased, there is nothing to trace. It is why destruction is deterministic — one owner, one end. It is why a spawn can mutate a value receiver without a lock — the value-typed-mutation chapter records that half. And when someone asked, idly, whether Zane could ever run on a GPU, the honest answer turned out to be that the value world already looks like what a GPU wants: a value-typed function at the Total Pure or Pure levels — alias-free, no capabilities, fixed-stride arrays underneath — is very nearly a compute kernel already, and the # mark that separates value from reference pre-draws the exact line a device backend would otherwise have to recover by analysis: the value subset is the offloadable part, the reference subset is the host. We never designed for a GPU. We designed the axis for concurrency, and a fourth use was sitting inside it.

That this keeps happening is not luck, and naming why it is not luck sharpens the strictness-is-performance bet into a more general principle than that chapter states. There, the framing was “forbidding a convenience is what licenses fast codegen.” The truer statement is that a restriction and an item of information are the same object seen from two sides. When we forbid a value type from holding a reference, the result is not merely a smaller language; it is a guarantee — an invariant the compiler may build on without proving. “Give up the convenience” and “hand the compiler a fact it can rely on everywhere” are one move in two vocabularies. Strictness for performance was always the special case; the general principle is information for performance, and codegen speed is only one of the benefits information buys. Automatic parallelism is another. GPU-shaped structure, it turns out, is another. The captured-intent bet makes this compose: because the source states intent and not mechanism, an invariant we banked years ago is free to pay for a mechanism — device offload — that had not been invented, from our point of view, when we banked it. See foundations.md §2.

The trap this insight sets is the reading that more restriction is therefore always more free value — that if invariants pay, the language should hoard them. It should not, and most restrictions are not worth their price. A rule earns its keep only when the invariant it creates is dual-use — load-bearing for more than one design downstream — and that, not severity, is the test we actually apply. Transitive alias-freedom is the standout precisely because it pays four separate consumers from one restriction: no collector, deterministic destruction, lock-free value-receiver concurrency, and now a natural offload boundary. A restriction that buys exactly one benefit is a tax; a restriction that buys four is a joint in the design, and cutting there is the mark of a well-chosen invariant. The most useful signal we have found for whether we cut at a real joint is exactly the GPU episode’s shape: an invariant that pays off in a place we were not looking, for a use we did not foresee, was almost certainly carving reality rather than our convenience. A restriction tailored to buy one known benefit can be over-fit to that benefit; one that keeps generalizing was tracking a real structure. So we read unplanned payoffs not as bonuses but as evidence — the design equivalent of a theory predicting a result it was not built to predict.

None of this implies that Zane runs on a GPU. It does not: there is no device-memory model, no kernel-launch or grid semantics, no offload trigger — the implicit-parallelism rule reserves the compiler’s right to schedule independent work but says nothing of where that work runs. What the foundations bought is suitability, not the feature — a value/reference split, a purity ladder, and a fixed layout that between them leave the offloadable subset already fenced off and already alias-proven, so that adding a device target would be building on prepared ground rather than re-litigating the whole memory model. The honest cost of the whole line of thinking is the trap named above: “information for performance” is a seductive enough principle that it can talk you into restrictions for their own sake, and the discipline that holds it in check — demand dual use, treat a lone beneficiary as a warning — is a judgement call every time, not a rule the language can enforce on its own designers.