name: moxie
description: Use when writing, reviewing or debugging Moxie (.mx) code, or working on the Moxie compiler, runtime or stdlib. Moxie is a compiled systems language: a tree of domains (threads in one process), one arena stack per domain, no heap, no GC, no goroutines, no reflection and no empty interface, explicit-width integers, string=[]byte, | for text concatenation, channels and select for event dispatch.
The normative documents are in docs/. This sheet is the condensed form;
decisions.md says which designs are real. When this sheet and
the code disagree, the code is the record and this sheet is the bug.
Moxie is not Go. These are compile errors, not warnings:
| written | why | instead |
|---|---|---|
int, uint | undefined names | int32, int64, uint32, uint64 |
s + t on text | no + on slices | s \| t |
append | removed | push(s, v) - it grows |
make(T, ...) | removed | []T{:n}, []T{:n:c}, chan T{}, chan T{:N}, map[K]V{} |
new(T) | removed | &T{} |
any, interface{} | removed | an interface with at least one method |
reflect | removed | nothing needs it: every builtin has String(), every boundary has a codec |
recover | removed | panic is death; deferred calls do not run |
go f() | no goroutines | spawn starts a domain thread |
fallthrough | removed | case A, B: or a shared function |
import "strings" | removed | bytes (string is []byte) |
import "sync" | removed | one thread per domain |
| unnamed result | rejected | func f() (n int32) |
| value receiver on a struct | rejected | pointer receiver (a struct value is a copy) |
var x = expr at package scope | rejected | var x T, assign in init() |
int8(1000) | constant overflow | the value must be representable |
string and []byte are one mutable type, identical 3-word layout.len() and cap() return int32; indexes are int32.String() string; fmt takes ...Stringer.[]T compares with ==/!= when T is comparable.s[a:b] allocates. A write through it does not reachthe parent, and neither does a write through a subslice passed as an argument.
No heap, no GC, no free. Every allocation goes to fnStack[fnTop]: a
per-function arena released at return, a manual phase arena released at
ManualArenaExit, a sovereign arena owned by a self-mutating receiver, or the
root arena of the domain. Return values are encoded in the callee's frame,
FnArenaPop releases it, and the caller decodes into its own arena. Parameters
are owned by the caller; anything in the frame not attached to a named result is
gone at return. push grows by itself - for one element, several, or a spread -
so there is no capacity guard to write and no growth helper to call; a helper
that returns a pointer-bearing slice is deep-copied by the return protocol and
is quadratic when used in a loop.
loop. No scheduler, no preemption, no locks.
chan T{} is one slot. There is no unbuffered channel; :0 is an error. chan T{:N} is N outstanding messages; chan T{:N:bytes} declares the frame
budget.
spawn(fn, args...) copies values and shares channel handles. A spawn target's single result MUST be named closed and be of type chan struct{}.
never spawn on demand. Termination is cooperative - the breaker arm goes at every wait.
[]T{:n} and write through a cursor when the count is known.heavy scratch into a free helper.
wrong before the code is.
Run it. A claim backed by recollection is not backed by anything; a claim backed
by a build and a run is. Every compiler change lands in legacy/ first and
_mxc_stage4/ second (wood law), unless it changes no emitted code - and say so
explicitly when that is the reason.