moxzi 0.1.0-alpha.11 — Motoko 2.2.3, core 2.7.0, and safer upgrades
Hi everyone,
moxzi alpha.11 is out. If you haven’t met it: moxzi is a Motoko compiler written in Motoko. The same compiler runs on your laptop, in your browser, and as a canister on the Internet Computer, where it can build your project on chain so anyone can check what was compiled from what.
This release catches up with upstream: moxzi now follows moc 2.2.3 (it followed 2.0.0) and supports core 2.7.0. Here’s what that means for you.
1. What’s new in the language
Everything moc 2.1–2.2.3 added, with the same error codes:
async*can return any type, including types that can’t be sent between canisters and type parameters. Futures (async T) still need shareable types.- Lambdas just work as async callbacks:
forEach(xs, func(n : Nat) { … })where anasyncfunction is expected is now asynchronous, asfunc(n) { … }already was. - Timers survive running low on cycles: a job that couldn’t be dispatched is retried once cycles are back.
- A late
awaitof a future whose reply trapped runs itsfinallyblocks. - New primitives for pay-as-you-go HTTPS outcalls:
Prim.costHttpRequestV2andPrim.subnetSelfNodeCount.
2. core 2.7.0: sorting and printing records for free
core 2.7.0 derives toText, equal and compare for records, tuples and variants. Import Records (or Tuples, Variants) and this works with no hand-written comparator:
let people = [{ name = "Bob"; age = 30 }, { name = "Alice"; age = 25 }];
people.sort().toText()
Using core 2.7.0, and running its own test suites under moxzi, found four moxzi bugs where moc was right — xs.sort().toText(), pair.compare((1, "a")) and nested generic calls like List.tabulate(n, func i = …).flatten() either failed to compile or built a module no runtime would load. All fixed, and core 2.7.0’s suites now behave identically under both compilers.
3. Upgrades: one thing to know before you deploy
moc 2.2.1 changed how a canister describes its stable variables, so it can tell [var T] from a var [T] field, Char from Nat32, and () from Null. moxzi now writes exactly the same description.
- Upgrading to alpha.11 keeps your data. Canisters built by earlier moxzi releases or by moc upgrade with their values intact — including moxzi’s
Nat128/Nat256. - Unsafe upgrades are refused. Swapping one of those pairs used to be accepted and then read the old values wrongly; it now fails with
Memory-incompatible program upgrade. - No way back for some canisters. After its first upgrade to alpha.11, a canister whose stable variables contain
[var T],Char,()or a variant tag without a payload can’t be downgraded to alpha.10 or to moc 2.2.0 or earlier. Test the upgrade on a copy first.
4. moxzid: crash-safe training on the GPU
If you train models from actors on moxzid’s tensor device: a crash in the middle of a timer callback used to apply that callback’s device work twice, so the run drifted from one without the crash. Now the callback picks up where it stopped. A training run killed with kill -9 ends with exactly the same losses as one that wasn’t.
5. Smaller things
switch (a, b) { … },switch (f()) { … }andf().0no longer allocate a tuple on the heap — a tight loop switching over pairs could previously run out of memory where moc’s build did not.- The ten
moxzi-*kernel packages are 0.1.1 (core 2.7.0, no deprecated calls); the kernels themselves are unchanged. moxzi infonow says what its numbers are (the compiler’s exported methods) and that it never touches the network.- Known gap: moxzi doesn’t report moc’s warning for calls to deprecated library functions yet. core 2.6.0 deprecated many
fromXconversions (Nat8.fromNat→Nat.toNat8), so runmoconce after updating core.
Try it
- Install or update: https://moxzi.ai (one command on macOS and Linux).
- What changed in detail: the release notes on moxzi.ai.
Questions, bug reports and “this broke my project” are all very welcome — reply here, or write to austin at rivvir dot com.