Repository navigation
Releases
Mimic nightly 0.4.3-nightly.20261129
A nightly build of the development branch: not a stable release. Install it with mimic upgrade --nightly.
Added
- C structs in a hand-written
extern "C"block:struct pollfd { fd: i32, events: i16, revents: i16 }with the functions that use it, imported as a trusted header would be (the recordc::Pollfd, taken and given by those functions) but with only what the block declares, so the audit does not warn about trusting a whole header. Reported by a user. mimic whysays why a map stays off the GPU: on macOS, a fused map with no GPU kernel gets a note with the reason (it computes in f64, reads another list, or calls a function with no GPU version), where only the maps that went there were shown. Reported by a user.term::poll_key(ms): a key, orNonewhen none is typed withinmsmilliseconds, so a real-time program (a game's loop) reads keys without stopping. And Ctrl-C restores the terminal: in raw mode, Ctrl-C, SIGTERM or a closed terminal ended the program without restoring it (raw mode, a hidden cursor and the alternate screen stayed); the terminal is restored, the cursor shown and the normal screen brought back first (unless the program setos::on_interrupt). Both reported by a user's game.- Constants:
const width: f64 = 80.0at module level (glyph≝, digraph\c;pub consttoo), usable wherever an expression is. A list, text or record constant is worked out the first time it is used, then shared; a constant's value cannot have effects (E0606). Reported by a user's game, approved by the owner. - Typed maps
[K: V]: a map's key and value types, declared (let m: [str: i64], parameters, record fields) or worked out from a literal. A lookup has the value's type (a plain number inm[k] + 1),getgives a typedOption,keysandvaluestyped lists; a key or value of another type is refused when checking (E0401), an integer next to floats promoted as in a list. - Sized lists
[T × n](also[T * n]):[f64 × 3],[i64 × 9], a list with its length in its type, for parameters,lets, results and record fields. Up to 16 numbers are kept in registers. A written-out list of another length, or a constant index outside it, is refused when checking (E0217; a call with a list of another known length, E0401); a list of unknown length is checked where it is bound;[f64 × n]turns integers into floats. - Assignment into nested lists and records:
g[r][c] = v,s.pos.x = v,l.todos[1].done = true, and+=and the like on them, on alet mutvariable. Each level is changed in place when nothing else holds it and copied once otherwise: 4 million writes into a 2000×2000 grid take 0.7 s (a row copied each time before: 63 s), and a record's list field changed in a loop is no longer copied per step. random::at(seed, i)andrandom::at_float(seed, i): thei-th random number from a seed, with no state, so a program makes its input on every core (⍳ n ¨ (i => random::at(seed, i)): 50 million numbers in 0.16 s on a 12-core Mac) and gets the same numbers on every run.- Loops:
for,whileandbreak(∀,⟳,↯; digraphs\F,\O,\B):for i in a ‥ b { … }over a range,for x in xs { … }over a list's elements,while cond { … }, andbreakto leave the innermost loop (E0216 outside one, or inside a lambda). A loop changes its function'slet mutvariables, one step after another; parallel work stays with¨and the array primitives.settle,evolveand recursion are unchanged. Tutorial chapter 4 and the syntax reference describe them; the editors' grammars know them. - Compound assignment
+=,-=,×=and÷=(ASCII*=/=; glyphs+↩-↩×↩÷↩) on alet mutname or a list element:total += i,counts[k] += 1. An index other than a name or a number is computed once.
Changed
join(⍳ n ¨ (k => …text…), sep)makes no list of texts: each text is appended to the result as it is made and released, where a list of n texts was built and joined after; a pure function that calls the program's own functions keeps the parallel map when the program has several workers (chosen when running).translit(8 million texts) 0.83 s → 0.30 s on one core, 0.40 s → 0.28 s on all cores;aho0.58 s → 0.38 s on one core, the same on all.- Output is written before a C call that replaces the process: what a program printed just before
execl(orfork,_exit,system, …) was lost when its output went to a pipe or a file (buffered); it is flushed first now. Reported by a user. mimic test file.mimworks on a file of a project: it was refused (E0903, a library module used on its own); it builds the project and runs that file's tests only, from anywhere. Reported by a user.build.mimsettings are checked: an unknown setting, or a value of the wrong kind (opt = 7,leak_check = 1), is an error naming the nearest known setting, where a misspelt one was silently ignored. New:strict_math = truein a profile, as--strict-math(--fast-mathoverrides it). Reported by a user.MIMIC_GPUvalues are checked, and1has a floor:0/offnever uses the GPU, unset orautolets the runtime decide,1/onsends maps of 65,536 elements or more (a smaller one costs more to start than it saves),alwaysevery map (what the tests use); any other value stops the program with a message, where2,defaultor the empty text meant "always". Newos::unset_env(name). Reported by a user's game.- Functions passed to a parameter of a declared function type are typed: with
more: fn(i64) -> bool, a lambda passed asmoreworks on integers (it was typed with unknown arguments, its arithmetic the runtime's generic operators), and a callmore(x)gives abool.tokenizetwice as fast (0.87 s → 0.43 s on one core). - Searching text jumps to its first byte:
find,contains,replaceandsplitcompared the part at every position; they look for its first byte with the C library's vectorisedmemchrnow, then compare the rest.url35% faster on one core (3.27 s → 2.11 s),http_parse44% (1.21 s → 0.68 s),ini8%. - A loop's tuple state changes its list in place: in
settleandevolve, a step such as(s.0 + 1, put(s.1, k, v))copied the list each step, as the state still held it. The step owns its state now, and a field it reads once as the listput,pushorconcatchanges is taken out of it and changed in place (a start state still held elsewhere is copied as before).huffman's decoding table: no values made in the loop's steps, 0.12 s → 0.10 s. - A shared list of numbers written by index is copied in one pass:
putorxs[i] = von a list held elsewhere copied it element by element; it is one copy of the bytes now (huffman, whose decoding table of 512K numbers is written from a loop's tuple state: 0.18 s → 0.12 s on an M3 Pro). - A list a loop only reads and writes element by element is checked once, at the loop's start: a
let mutlist of numbers that afororwhilebody uses only asxs[i],xs[i] = vand≢ xsis made held once there (copied if shared, as its first write would have) and its kind and length checked; each element write in the loop is then a bounds check and a store, with no atomic read of its count.levenshteinwritten with loops 14% faster.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.3-nightly.20261129-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.3-nightly.20261129-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.3-nightly.20261129-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.4.3
Step 0.4.3, loops and values in registers: a memory check in debug builds that stops at the first use of a freed value; every run fixture checked five ways in CI, and random valid programs run the same ways (seven daily seeds on the frozen release, rerun until all agreed; the three bugs they found fixed: an element of a list in registers assigned with an index of unknown type, a list released inside a later argument of the call holding it, and list headers and record fields read as never-changing memory, which let a read move past a release; that last fix gave back some speed, accepted by the owner: lcs up to 20% slower, regex 5–6% on one core); and the held-out set (40 programs written plainly, never used for tuning) made faster without a change to them: Mimic's time over C's on one core, as a geometric mean, from 4.65× to 3.61× on Linux, 4.18× to 3.17× on macOS and 4.33× to 3.33× on Windows. Loops that grow a short list, tuples holding lists and the steps of qoi go through the Mimic IR; text mapped character by character is one pass (caesar 2.7× faster); a function value capturing nothing is made once; push onto a short list stays inline; Windows release executables are a third of their size; ⍬ and x ⥊ [n] are typed; and tools/rc-count.py counts the values made in loop steps. Moved to 0.4.4, with the owner's approval and recorded in docs/versions.md: qoi within 1.5× of C and paths within 1.3× (now 1.9× and 1.75×), escape analysis, loops making no values in their steady state, and the gaps.md rows still open for 0.4.3.
Added
- Values made in loop steps, counted: a
MIMIC_COUNT_RC=1build also counts the values made while anevolveorsettlestep runs (past each loop's first step, which may copy a start still shared elsewhere), andtools/rc-count.pylists the benchmarks whose loops make any in their steady state. - A matrix row assigned in one write:
m[i] = [10 40 70]replaces rowi(a number fills it; with more dimensions, fewer indices than dimensions replace that cell,cube[1, 0] = [7 8]), copied first when shared, a byte matrix keeping bytes. It stopped the program withneeds one index per dimension; a list of the wrong length says how long the row is. - Character literals:
`a`is the number 97 (a character's code, aschar_code("a"); escapes`\n`,`\,\x1b,\u{e9}). Text work on bytes compares and computes with characters as numbers,(c -a+ 13) % 26 +a``, instead of making a one-letter string for each one. ⍬, an empty list with a type (digraph\z):⍬is an empty[i64],⍬[f64],⍬[str],⍬[Point]an empty list of that element type. A bare[]has no element type and, where nothing gives it one, sent the code using it the slow generic way; the prelude's[0] ↓ 1(and[0.0] ↓ 1, …) for an empty typed list is now⍬.- Every keyword has a glyph, each with a digraph:
⇑pub,⇄mut,⍰if,⋄else,⏎return,⇐use,≔as,⌁extern,☡unsafe,✓trusted,⊡type,⊨match,⊕with,●true,○false, and⊢test,∀for (property tests),⎘include, beside§module andƒfn. Words and glyphs mix freely;mimic fmtwrites glyphs back as words,mimic glyphslists them all, and the editor grammars (TextMate, tree-sitter) colour them as their words. e else { … }is an expression: the value inside anOptionorResult(Some,Ok), else what the block gives, anywhere an expression goes:if 1 < ≢ args { parse_int(args[1]) else { 1086 } } else { 1086 },xs ¨ (s => parse_int(s) else { 0 }), andlet port = parse_int(s) else { 8080 }(the block may still leave withreturn, aslet … elsedid). The block must give the type inside (E0401) or something (E0504); a value that is not anOptionorResultis E0406.Resultgets its fallback this way too.- A memory check in debug builds. A freed value is marked, filled with junk and kept a while before its memory is used again; retaining, releasing or reading it afterwards stops the program at once, naming what was done and what the value was (
memory check: a value ([i64], 4 elements) was read after it was freed).mimic lldbstops right there, with the stack. Release builds are unchanged. - Random programs, nightly (
tools/fuzz.py, thefuzzworkflow): valid programs written at random (numbers, lists, functions that call themselves with a list they grow, copies changed in place) run in release and debug, without the Mimic IR, on one thread and on many; all must print the same. A disagreement is kept with each way's output, to become a fixture. math::to_bits,math::from_bits(andto_bits32/from_bits32forf32),bytes::of_f64sandbytes::to_f64s: a float's bits as an integer, and floats as little-endian bytes, both exact (weights saved and read back bit for bit).∧/and∨/, the and and or reductions (allandanywritten as glyphs, as in APL):same ▷ ∧/,∨/ flags.math::tanh,math::sinh,math::cosh,math::log1p,math::expm1andmath::sigmoid(libm calls that fuse into array kernels likemath::exp;log1pandexpm1exact near zero;sigmoidwithout overflow for large negative inputs), andunwrap_orfor anOption:parse_int(s) ▷ unwrap_or(300). Reported by a user.
Changed
- Text mapped character by character is one pass:
chars(t) ¨ (c => …) ▷ join(sep)with a function giving text walks the bytes oftonce, hands the function each character and appends its text at once: no list of one-character strings made, none joined. A pure function is asked once for each ASCII character, its texts kept for the rest of the loop. The held-outcaesar2.7× faster on one core;translitadded to the corpus for it. pushonto a short list stays inline: a list of numbers in one of the runtime's pools (up to 256 bytes) told the compiled code nothing of its room, so everypushonto it called the runtime, which looked up its block's size. The compiled code now knows the pools' sizes. A row grown to 45 numbers called the runtime for its first 32;levenshtein32% faster.- A function value that captures nothing is made once:
run(b, p, x => alpha(x) or digit(x))orrun(b, p, digit)made a new function value at every call and freed it after; one is now made the first time and shared, never freed.tokenize's scanning loop made 1.07 million values, now none; 8% faster. - A tuple holding a list, taken apart at once, stays compiled whole:
let (bytes, op) = chunk(p, prev), a tuple of 2 to 4 numbers, lists and records, no longer sends the function back to the old code generator. The Mimic IR calls the version of the callee that gives its parts (no tuple made) and holds each part as a value of its own, a part not named released at once.qoi'sencode_stepanddecode_stepare now compiled whole. In a record update, a short list kept in registers is appended with no list made for it,concat(s.px, p ⥊ [n])appendsncopies in place, and an empty list appended is no call at all. - A loop that grows a short list stays compiled whole:
first ▷ evolve(48, w => push(w, …)), its start a list of up to 16 numbers kept in registers and its state a list on the heap, puts the start on the heap once and pushes in place at each step. The loop went back to the old code generator, which copied the list at everypush:sha256's message schedule freed 97 values per block, now 1 (3.18 million values in the benchmark, now 33 thousand). gather(^),gather(&),gather(|)(andtrail) over integers fold in a loop, asgather(+)does: the runtime's generic fold called a function value with two boxed numbers for every element.siphash(hashes ▷ gather(^)): reference-count operations from 4 million to 8, 25% faster on one core.[256 -1 255]is three numbers: in a list written out, a-with a space before it and a digit right after is a negative element, not a subtraction (which gave[255 255]with no error).[a - 1],[a-1], an indexxs[n -1]and parentheses inside a list still subtract;¯1works everywhere as before.- A list of strings written out and indexed at once makes only the element picked:
["" "-alpha.{k}" "-beta.{k}"][i], its elements literals, variables or text formatted from them, is a switch onithat formats one string, not the list and every string in it (an index outside it: the list made and indexed as before, the same error).semver: reference-count operations from 41 million to 20 million. - A list of lists no longer sends a function back to the old code generator: the Mimic IR holds, passes on and releases it as any other list (its rows read by the old path, as for a list of strings), so the rest of the function is compiled through the IR.
vm, whose program is a list of[operation, argument]pairs: its machine loop compiled whole, reference-count operations from 46 million to 51, 4× faster. - A loop whose state is a record or short list kept in registers is compiled whole, a short list read and changed at any index there too:
xs[i]andput(xs, i, x)on a list of up to 16 numbers kept in registers (a machine's tape in its record) are checked against its length and stay in registers, so a step changing it no longer builds the whole state on the heap to do so. A loop's first state with an empty list in it,(0, []), takes the list's type from the step.brainf: reference-count operations from 42 million to 5 thousand, 3× faster. - A tuple of a list and a number (and such: 2 to 4 numbers or values on the heap) is returned as its parts: where the caller takes it apart at once (
let (p, root) = find(parent, i)), the function gives its parts in registers, with no tuple made, filled, checked and freed; a tuple written out as the result, in any branch, or handed on from another such call, makes none. A caller that keeps the tuple gets one,...
Mimic 0.4.3-preview.1
A preview of the next version: not a stable release. Install it with mimic upgrade --preview.
Step 0.4.3, loops and values in registers, so far (0.4.3-preview.1): a memory check in debug builds that stops at the first use of a freed value; every run fixture checked five ways in CI and random valid programs run the same ways each night; and the held-out set (40 programs written plainly, never used for tuning) traced and made faster without a change to them: Mimic's time over C's, as a geometric mean, from 4.65× to 3.67× on Linux, 4.18× to 3.24× on macOS and 4.33× to 3.44× on Windows. A tuple of a list and a number is returned as its parts, ¨ over lists of strings and lists of lists is one compiled loop, v[i] = x changes a let mut list in place, join writes its string once, lists of truth values keep their type, and settle/evolve over a record or a list go through the Mimic IR: histogram 15×, bfsgrid 4.4×, unionfind 2×, sudokucheck 2× faster; markdown, soundex and template 17–29%. qoi's encoder and decoder steps no longer allocate.
Added
- A memory check in debug builds. A freed value is marked, filled with junk and kept a while before its memory is used again; retaining, releasing or reading it afterwards stops the program at once, naming what was done and what the value was (
memory check: a value ([i64], 4 elements) was read after it was freed).mimic lldbstops right there, with the stack. Release builds are unchanged. - Random programs, nightly (
tools/fuzz.py, thefuzzworkflow): valid programs written at random (numbers, lists, functions that call themselves with a list they grow, copies changed in place) run in release and debug, without the Mimic IR, on one thread and on many; all must print the same. A disagreement is kept with each way's output, to become a fixture. math::to_bits,math::from_bits(andto_bits32/from_bits32forf32),bytes::of_f64sandbytes::to_f64s: a float's bits as an integer, and floats as little-endian bytes, both exact (weights saved and read back bit for bit).∧/and∨/, the and and or reductions (allandanywritten as glyphs, as in APL):same ▷ ∧/,∨/ flags.math::tanh,math::sinh,math::cosh,math::log1p,math::expm1andmath::sigmoid(libm calls that fuse into array kernels likemath::exp;log1pandexpm1exact near zero;sigmoidwithout overflow for large negative inputs), andunwrap_orfor anOption:parse_int(s) ▷ unwrap_or(300). Reported by a user.
Changed
- A tuple of a list and a number (and such: 2 to 4 numbers or values on the heap) is returned as its parts: where the caller takes it apart at once (
let (p, root) = find(parent, i)), the function gives its parts in registers, with no tuple made, filled, checked and freed; a tuple written out as the result, in any branch, or handed on from another such call, makes none. A caller that keeps the tuple gets one, as before. Held-outunionfind6.2 s → 3.2 s,bfsgrid1.3 s → 0.45 s,textstats18% faster. char_of(n)of a number takes it as it is: no boxed number made and checked for each character (the same errors for a number that is not a character). The held-outcaesar12% faster.- A list of truth values is typed as one when passed or returned: a parameter declared
[bool]given[](or a list of unknown type) is compiled for[bool], the list converted once at the call, and a function declared-> [bool]gives back a typed list, as[i64]and[f64]already did. The held-outbfsgridread its walls through the generic path at every step: 2.0 s → 1.3 s. joinwrites its string once: the length is added up first and the parts copied into the new string, instead of a buffer grown (and reallocated) as it goes and then copied again. A word of a few letters joined millions of times: the held-outtextstats24% faster.v[i] = xon alet mutlist of numbers is written in place, with nothing counted per step: the number stored directly where the list is held once (else copied first, as before, with the same errors);v[i]read without a reference of its own; andlet mut v = xs, changed and then handed on (fill(n - 1, y, v)), moves the list there instead of keeping a reference. The held-outhistogramabout 15 times as fast.xs ¨ fover a list of lists is one compiled loop (split over the cores when long): each row is lent tofas it is, a lambda that captures or a named function, which returns a number, a truth value, a string or a record (g ¨ (row => row[c]),rows ¨ group_ok). The held-outsudokucheckabout twice as fast.xs ¨ fover a list of strings is one compiled loop (split over the cores when long), as it already was over numbers and records:f, a lambda that may capture values (chars(text) ¨ (c => shift(c, k))), gets each string lent and returns its string or number directly, instead of one boxed call per element with its arguments checked each time.markdown,soundexandtemplate17–29% faster; the held-outcaesarfrom 50× C to 35×.settleandevolveover a record or a list are compiled through the Mimic IR, as they already were over numbers and values kept in registers: the loop holds the state, each step takes it on (changing it in place) and the first state is left as it was when it is still read after the loop. A record built from short lists (S { heap: [x], … }) goes through the IR too.paths' search is in the IR now.concat(s.f, v ⥊ [n])on a record's list of numbers writes thencopies into the list itself when the record holds it alone: no list of them is made first and joined (qoi's decoder repeating a pixel for a run).if c { [x] } else { [] }taken at every step allocates nothing for the[]: a[]typed by the branch next to it is one shared empty list, made once (a change to it copies, as to any shared list), andconcat(s.out, flush)with an emptyflushleaves the record's list as it is, without a call. A QOI encoder's flush of a run: 46 ms → 29 ms a frame.- A small helper returning a tuple, unpacked just before a record update, no longer allocates:
let (bytes, op) = chunk(p, prev)followed by{ s with out: concat(s.out, bytes), ops: put(s.ops, op, …) }inlineschunkand makes the update in each of its branches, wherebytesis a list of known length kept in registers and appended to the record's own list in place;concat(s.out, concat(flush, bytes))growss.outinstead of building the inner list.qoion one core: 0.87 s → 0.47 s. - A record's list grows in place when the new list is chosen by an
iffirst:let out = if k == 0 { push(s.out, x) } else { concat(s.out, ys) }followed by{ s with k: s.k + 2, out: out }gives each branch the update, so a record held once has its list changed in place (as{ s with out: push(s.out, x) }already did) instead of copied at every step. An LZ77 decoder'ssettleover a 512 KiB output: 1.71 s → 0.03 s. push,putandconcatof a short list on a record's list of numbers are done inline when the record holds the list alone and it has room: the numbers are stored and the length raised where the code runs, without a call into the runtime (asputon a variable's list already was). A QOI encoder written with them: 0.49 s → 0.35 s on one core.if c { xs } else { [] }is a list ofxs's numbers ([i64],[f64]or bytes), not a list of unknown type: the[]takes the other branch's type, as a literal number already did, so code using the result is compiled for its numbers instead of the generic path.- Lists of lists are typed by their rows (
[[i64]],[[f64]], a matrix built by⍳ n ¨ (r => ⍳ n ¨ …)):grid[r][c]is a bounds check and a load, where it was two lookups through the runtime with type checks. Conway's Life on a list of rows: 161–338× C before, 5.4× now. - Text one character at a time is faster:
charsandchar_ofshare one string per ASCII character instead of making a new one each time, andchar_codeof ASCII text is read in place (of a literal,char_code("a"), it is a constant). A Caesar cipher over 10 MB: 8.8 s to 3.2 s, 1.27 GB to 365 MB. put(xs, i, xs[j])changesxsin place when it is the list's last use, also as the first argument of another call (insert(put(xs, j + 1, xs[j]), j - 1, v)): the element is read first. It copied the list at every call; a hand-written insertion sort of 20,000 numbers went from 4.4 s and 3 GB to 0.37 s and 2.5 MB.xs ↑ kandxs ↓ kshrink the list in place where it is used for the last time and held nowhere else (a heap's pop,h ↑ (n - 1), copied the heap every time); a read guarded by anifafter the take (if n > 1 { rest[0] = h[n - 1] }) is made before it. A heap of a million numbers used over 4 GB; it uses 11.5 MB.- A float prints as the shortest text that reads back as the same number (
"{x}",print): 15 significant digits where those do, as before, and 16 or 17 where they do not, soparse_float("{x}")is alwaysx.0.1 + 0.2now shows as0.30000000000000004, as in Rust, Go, JavaScript and Python. - A list returned in a tuple, or handed back to the function that holds it, is changed in place:
let (p, root) = find(…)movespat its one use, a list passed to the function itself or returned in its result is handed over, and a variable read by another argument of the same call (find(parent, parent[i])) is let go once the arguments are read. A union-find over a million elements used over 4 GB; it now uses 137 MB. - A pure
¨over a short list runs on one core unless its elements are worth sharing out: up to 16,384 elements, a function's first such¨is shared out as before while its cost per element is timed, and later ones go to the other cores only when that cost pays for waking them (else they run on one core, timed as they go). A sudoku ...
Mimic 0.4.2
Step 0.4.2, ownership by analysis: in the functions the Mimic IR compiles, a list or record is released right after its last use, handed over instead of shared, and changed in place wherever nothing else holds it, through helper calls, record updates and branches, in debug builds as in optimised ones. Text and functions that call several others now go through the IR too, numbers and literals that live for the whole run are never counted, and operators on values of unknown type no longer allocate their results. Reference-count operations over the corpus fell by 40% (937 million to 563 million, short of the halving the plan aimed at; what is left is mostly in code the IR does not cover yet). mimic check --copies lists the copies a program still makes and why: paths' step makes none; qoi's steps are still compiled by the old code generator (they wait for typed empty lists and tuples holding lists, 0.4.3–0.4.4). sudoku 1.9× faster, vm 1.7×, tokenize 1.5×, totient 1.3×, paths 1.27×, hull 1.2×, lz77 1.18× on this machine; the whole corpus on Linux, macOS and Windows is in BENCHMARK.md.
Added
mimic check --copieslists every copy of a list or record the program still makes, where, and why: aput,pushor{ … with … }on a value used again later (and at which line), read from outside a loop, or borrowed from the caller. Functions the compiler does not analyse yet are listed with the reason.--emit-jsongives the same as JSON.
Changed
- A step function takes its record state wherever it hands it on or updates it last: a record parameter read first (
let p = ps[s.i],s.v[i]) and then passed to a function that changes it, or used as the base of a{ … with … }, is now taken over, so the change is made in place instead of on a copy:look(look(s, 0), 1),{ grow(t, at) with k: t.k + 1 },let e = learn(d, c)aftercodes[d.i]. And a field changed in one branch and kept in the other (next: if d == 0 { push(k.next, w) } else { k.next }) is two updates, the one taken in place. These shapes took minutes in 0.4.0 (docs/gaps.md); the corpus already avoids them. - A list field changed under a
letand stored back is changed in place:let table = put(s.table, h, x)then{ s with table: table }copied the whole list (the record still held it when theputran); the change now happens in thewith, which takes the field out of the record, so it is made in place when nothing else holds them. The same for chains ofputandpush, and{ s with out: concat(s.out, ys) }now appends in place in the functions the IR compiles.lz77is 15% faster (its table of 65,536 entries was copied for every byte). - Values are released as soon as they are last used, and handed over instead of shared (docs/design/ownership.md): in the functions the IR covers, a list or record is freed right after its last use (not at the end of its block), given as it is to a function that takes it over, and stored into a record without a new reference. A field read borrows its record. Records on the heap,
{ r with … }and functions that take over a record argument now go through the IR;floydis 1.26× faster. putandpushon a list ofi64change it in place when nothing else holds it: a list the function owns at its last use (let g = push(h, x),put(put(h, p, b), i, a)) is changed where it is, and{ s with v: put(s.v, i, x) }stores the number in place without a call. A function whose list parameter is changed this way at its last use (a heap's sift-upup(put(put(h, p, b), i, a), p)), or handed on to one that is, now takes the list from its caller, so the change is in place there too. Before, a bareputalways copied the list.- Releasing a number,
true,falseor a literal no longer calls the runtime: these values live for the whole run, and compiled code now skips them where it releases a value. They were half or more of all reference-count operations invm,soundexandurl;vmis about 4% faster. - Text, and functions that call several others, now go through the IR: functions that take or return strings, and blocks with more than one call (only blocks the compiler would actually run in parallel, or start as a task, stay on the old path), now get release-at-last-use and in-place updates.
sudokuis 1.9× faster,paths1.27×;put/pushon a list a function only borrows copies it directly instead of taking a reference first.MIMIC_IR=whyprints why a function stays on the old path. - Comparing or computing with two numbers of unknown type no longer allocates: an operator on two single values whose type the compiler does not know (
op == 0in an interpreter's loop) gave a new value every time; a truth value or an integer from such an operator, and fromnot,-and∣on one value, is now the runtime's owntrue/falseor cached small integer.vmis 1.7× faster (8× fewer values freed),tokenize1.5×,brainf6% faster.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.2-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.2-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.2-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.4.1
Step 0.4.1, the Mimic IR: programs are now compiled through a typed intermediate representation between the syntax tree and LLVM, on by default, with fusion as a pass over it. Array code computed element by element (⍳ n, operators on lists, xs ¨ f, reductions) is fused by the IR, across lets and small helpers it inlines; what the IR does not cover yet is compiled by the old code generator where it stands, until that is retired (0.4.10). Also a security fix for the HTTP client's redirects, and the slowest benchmarks of 0.4.0 traced and most of them made several times faster without a change to the programs: tuples of numbers and short lists stay in registers, lists grown in a loop and lists from flatten stay typed, let lambdas and count's lambda are compiled as functions, gather/trail with a lambda are typed loops, and debug builds change lists in place. fnv1a, crc32, adler32, pagerank, topo and siphash 7–25× faster, sha256 13×, diff 7×, utf8 5.6×; no benchmark slower on Linux, macOS or Windows.
Added
- The Mimic IR (docs/design/ir.md): a typed intermediate representation (SSA, with structured control flow) between the syntax tree and LLVM, with passes over it: fusion, sinking (work moved into the one branch that needs it) and inlining of small helpers.
MIMIC_IR=printshows each function's IR,MIMIC_IR_ONLY=textsends only the functions whose path holdstextthrough it.
Security
- The HTTP client keeps credentials to the server they were meant for. A redirect from
httpstohttpis refused with anErr(the request would go on unencrypted), and a redirect to another server (a different scheme, host or port) leavesAuthorization,CookieandProxy-Authorizationbehind; other headers still go along. Before,http::requestsent them on to wherever it was redirected.
Changed
- Programs are compiled through the Mimic IR: the functions it covers (numbers, values kept in registers, loops,
match, lists read and owned, reductions, lists computed element by element) go through it, and what it does not cover yet is compiled by the old path where it stands. The same output and speed;MIMIC_IR=0turns it off. - Fusion is decided by the IR: a list computed element by element and read once by a later computation is never built (
let ys = xs × 3,let zs = ys + xs,zs ▷ +/is one loop), nor is a small one read several times (computed again where it is read);xs ¨ ftakes part, and so does a small helper, inlined first (fn sq(xs) { xs × xs }thensq(v) ▷ +/is one loop). +/ ×/ ⌈/ ⌊/of a list of numbers is the fused engine's kernel (SIMD, split over the cores) instead of the runtime's generic call, its result unboxed.- Lists grown in a loop stay typed:
pushof a number onto a list of that kind of number gives such a list, a loop whose list state changes length (⍳ 16grown to 64 bypush) keeps it typed, and a tuple holding short lists of known length ((i, [8 words])) stays in registers.sha25613× faster (4.7 s → 0.35 s). - A function declared
-> [i64](or[f64]) returns a typed list: a body joining[]with[x]gave a list of unknown type, which the declaration only checked, so the caller worked on boxed values. The result is now made typed as it is returned.diff7× faster (3.8 s → 0.54 s). A function that returns something else under such a declaration now stops at its return instead of later. flatten(xs ¨ (x => …))of lists of numbers is typed: its result had no known type, so everything after it ran on the generic path; when the lambda gives a list of numbers, the result is that list of numbers.utf85.6× faster (4.0 s → 0.71 s).gatherandtrailwith a lambda over numbers are a typed loop:ways ▷ gather((x, y) => (x + y) % p)sent every pair through the runtime boxed; a lambda that gives back the same kind of number as the list's is now typed and folded in a loop. 3,000,000 numbers: 2.35 s → 0.08 s. A lambda giving another type keeps the general path.count(xs, x => …)is typed and fused: the prelude'scountcalled its lambda as a function value for every element; given a lambda, the call is now written out as its body,+/ (xs ¨ (x => …)).maze5× andmarkdown1.2× faster.- A list of literals is built once:
["M" "CM" "D" …]or[1 2 3 …]in a function was built again on every call; it is now built the first time and shared after (a change to it copies, as to any list held twice).roman2.1× faster (3.2 s → 1.5 s of CPU). - A lambda kept in a
letand only called is a function:let at = (x, y) => table[…], thenat(a, b), called the lambda as a function value, every argument boxed; it now becomes a hidden function taking what it captures as arguments, specialised like any function. 8 million calls in a map: 5.8 s → 0.03 s. A lambda used as a value, or one that assigns, returns or sees a variable that changes later, stays as it was. - Tuples of numbers stay in registers: a
settleorevolveover a tuple state (a sequential pass, a hash, a binary search) allocated and freed a tuple on every step; a tuple of numbers and truth values is now kept in registers, as records of numbers are.crc326.8 s → 0.79 s,fnv1a4.5 s → 0.62 s,topo5.1 s → 0.79 s (one core, macOS). - Small programs build faster: a one-line program in about 0.45 s instead of 0.6 s on macOS. The linker runs inside
mimicinstead of as a second process (which took ~0.1 s just to start), and the macOS SDK and OS version are read from their files instead of askingxcrunandsw_verson every build (~70 ms).MIMIC_DEBUG_PHASES=1also times code generation, the runtime and linking.
Fixed
pushonto a short list no longer reallocates every time: a list that had grown past its first block kept askingreallocfor more room on eachpush, though it had plenty.levenshtein(rows built a number at a time) runs 2.5× faster on macOS, more on Windows.MIMIC_IRandMIMIC_DEBUG_DISABLEare part of the build cache's key: a program built with one of them could be reused by a build without it (and the other way round).- A redirect to
//host/pathgoes to that host with the request's scheme; it was taken as a path on the same server. ALocationtoo long to follow is anErrinstead of a cut-short URL. - Debug builds update records in place, as optimised ones do:
{ s with f: put(s.f, …) }copied the whole list on every step in a debug build (functions never took over their parameters there). A debug sieve of 200,000 took over ten minutes; now 1.8 s. - A program with only small maps no longer opens Metal on macOS: the GPU was asked before the map's size was checked, and asking opens Metal (~0.13 s). A program over 1,000 numbers ran in 0.14 s; now 0.01 s. Large maps go to the GPU as before.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.1-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.1-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.1-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.4.1-preview.1
A preview of the next version: not a stable release. Install it with mimic upgrade --preview.
Step 0.4.1, the Mimic IR, so far (0.4.1-preview.1): its first part (functions of plain numbers through a typed intermediate representation, off by default), a security fix for the HTTP client's redirects, and the slowest benchmarks of 0.4.0 traced and most of them made several times faster without a change to the programs: tuples of numbers and short lists stay in registers, lists grown in a loop and lists from flatten stay typed, let lambdas and count's lambda are compiled as functions, gather/trail with a lambda are typed loops, and debug builds change lists in place. fnv1a, crc32, adler32, pagerank, topo and siphash 7–25× faster, sha256 13×, diff 7×, utf8 5.6×; no benchmark slower on Linux, macOS or Windows.
Added
- The first step of the Mimic IR (docs/design/ir.md): functions of plain numbers and truth values can be compiled through a typed intermediate representation, with the same results. Off by default while it grows:
MIMIC_IR=1turns it on,MIMIC_IR=printshows each function's IR.
Security
- The HTTP client keeps credentials to the server they were meant for. A redirect from
httpstohttpis refused with anErr(the request would go on unencrypted), and a redirect to another server (a different scheme, host or port) leavesAuthorization,CookieandProxy-Authorizationbehind; other headers still go along. Before,http::requestsent them on to wherever it was redirected.
Changed
- Lists grown in a loop stay typed:
pushof a number onto a list of that kind of number gives such a list, a loop whose list state changes length (⍳ 16grown to 64 bypush) keeps it typed, and a tuple holding short lists of known length ((i, [8 words])) stays in registers.sha25613× faster (4.7 s → 0.35 s). - A function declared
-> [i64](or[f64]) returns a typed list: a body joining[]with[x]gave a list of unknown type, which the declaration only checked, so the caller worked on boxed values. The result is now made typed as it is returned.diff7× faster (3.8 s → 0.54 s). A function that returns something else under such a declaration now stops at its return instead of later. flatten(xs ¨ (x => …))of lists of numbers is typed: its result had no known type, so everything after it ran on the generic path; when the lambda gives a list of numbers, the result is that list of numbers.utf85.6× faster (4.0 s → 0.71 s).gatherandtrailwith a lambda over numbers are a typed loop:ways ▷ gather((x, y) => (x + y) % p)sent every pair through the runtime boxed; a lambda that gives back the same kind of number as the list's is now typed and folded in a loop. 3,000,000 numbers: 2.35 s → 0.08 s. A lambda giving another type keeps the general path.count(xs, x => …)is typed and fused: the prelude'scountcalled its lambda as a function value for every element; given a lambda, the call is now written out as its body,+/ (xs ¨ (x => …)).maze5× andmarkdown1.2× faster.- A list of literals is built once:
["M" "CM" "D" …]or[1 2 3 …]in a function was built again on every call; it is now built the first time and shared after (a change to it copies, as to any list held twice).roman2.1× faster (3.2 s → 1.5 s of CPU). - A lambda kept in a
letand only called is a function:let at = (x, y) => table[…], thenat(a, b), called the lambda as a function value, every argument boxed; it now becomes a hidden function taking what it captures as arguments, specialised like any function. 8 million calls in a map: 5.8 s → 0.03 s. A lambda used as a value, or one that assigns, returns or sees a variable that changes later, stays as it was. - Tuples of numbers stay in registers: a
settleorevolveover a tuple state (a sequential pass, a hash, a binary search) allocated and freed a tuple on every step; a tuple of numbers and truth values is now kept in registers, as records of numbers are.crc326.8 s → 0.79 s,fnv1a4.5 s → 0.62 s,topo5.1 s → 0.79 s (one core, macOS). - Small programs build faster: a one-line program in about 0.45 s instead of 0.6 s on macOS. The linker runs inside
mimicinstead of as a second process (which took ~0.1 s just to start), and the macOS SDK and OS version are read from their files instead of askingxcrunandsw_verson every build (~70 ms).MIMIC_DEBUG_PHASES=1also times code generation, the runtime and linking.
Fixed
pushonto a short list no longer reallocates every time: a list that had grown past its first block kept askingreallocfor more room on eachpush, though it had plenty.levenshtein(rows built a number at a time) runs 2.5× faster on macOS, more on Windows.MIMIC_IRandMIMIC_DEBUG_DISABLEare part of the build cache's key: a program built with one of them could be reused by a build without it (and the other way round).- A redirect to
//host/pathgoes to that host with the request's scheme; it was taken as a path on the same server. ALocationtoo long to follow is anErrinstead of a cut-short URL. - Debug builds update records in place, as optimised ones do:
{ s with f: put(s.f, …) }copied the whole list on every step in a debug build (functions never took over their parameters there). A debug sieve of 200,000 took over ten minutes; now 1.8 s. - A program with only small maps no longer opens Metal on macOS: the GPU was asked before the map's size was checked, and asking opens Metal (~0.13 s). A program over 1,000 numbers ran in 0.14 s; now 0.01 s. Large maps go to the GPU as before.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.1-preview.1-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.1-preview.1-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.1-preview.1-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.4.0
Stage 0.4.0, the measuring stick: a benchmark corpus of 130 everyday algorithms (hashing, parsing, graphs, text, interpreters, compression, numbers, simulations, geometry, images, data structures and dynamic programming), each in Mimic, C and Rust and checked against an independent reference; the machine's limits; and a speed gate on Linux, macOS and Windows that fails CI on a slowdown. The corpus found the bugs and slow paths fixed below, and the gaps left for the rest of stage 0.4 (docs/gaps.md). Its algorithms also became standard modules: hash, text, graph, order, parse, compress, and whole numbers in math.
Changed
- The standard library's own records hold raw numbers, as a program's do: its private helper records (the state of
hash,graph,compress,math::primes…) kept every number boxed, so their loops ran 2–15× slower than the same code in a program (math::primes(10000000): 5.0 s → 0.35 s;compress::rleof 4 MB: 1.2 s → 0.15 s). Public types, which the runtime builds too, keep their layout. sieveandkmeansare written as one would write them:sievekeeps its flags in bytes, as C does, andkmeanspasses its centres as a record. Both workarounds are gone now thatputon bytes is in place and a record passed along a recursion is borrowed.- The speed gate times short benchmarks longer: each side runs until it has run for a second (at most 30 runs) before the best time is taken. Benchmarks of 50–130 ms raised false alarms of 6–22% with the best of 3.
- The gate's noise is measured as the gate compares:
bench/run.py --noisenow runs the gate's comparison with the same compiler on both sides; a benchmark too noisy for the 25% limit on a platform is reported there, not gated. (The first noise data, ratios to C across whole rounds, overstated it, and a preview's identical compiler failed the gate ontreeandui.) - Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (
bench/http/load/main.rs).
Added
- Whole numbers in
math, from the corpus:math::gcd,lcm,powmodandmulmod(exact for anyi64, with 128-bit products),is_prime(Miller-Rabin, exact for everyi64),primes(a sieve) andtotient, checked against Python and sympy. Golden testmath_whole, docs/std.md and the tutorial. compress, from the corpus:compress::rle/unrle,compress::lzw/unlzw(12-bit codes) andcompress::varints/unvarints(zigzag LEB128 deltas), checked against reference implementations in Python, with every round trip and each decoder'sErrfor input it did not make. Golden testcompress_module, docs/std.md, the tutorial (chapter 16) and man pages.orderandparse, from the corpus:order::lower_bound,upper_bound,select(quickselect) andmerge, checked against Python'sbisectandsorted;parse::csv(RFC 4180, against Python'scsv),parse::url(againsturllib.parse.urlsplit) andparse::semverwithsemver_compare(against the precedence chain of semver.org). Golden testorder_parse, docs/std.md, the tutorial (chapter 6) and man pages.graph, from the corpus:graph::bfs,graph::shortest(Dijkstra with a binary heap),graph::components(union-find),graph::topo(Kahn's algorithm,Nonefor a cycle) andgraph::mst(Kruskal), on nodes 0 … n - 1 and edges as lists, checked against networkx on graphs of up to 20,000 nodes. Golden testgraph_module, docs/std.md, the tutorial (chapter 6) and man pages.text, from the corpus:text::distance(Levenshtein, by characters),text::find_all(every occurrence, overlapping, by KMP),text::soundexandtext::wrap(greedy, as Python'stextwrap), checked against Python and Soundex's published examples. Every loop is a loop in debug builds too, so a pattern that falls back far or a long name cannot exhaust the stack. Golden testtext_module, docs/std.md, the tutorial (chapter 6) and man pages.hash, the first module graduated from the corpus:hash::crc32,crc64,adler32,fnv1a32,fnv1a64,murmur3,xxhash32,xxhash64,siphash,md5,sha1andsha256on bytes, checked at every length around their block sizes against Python'szlib,hashlib,xxhashandmmh3and the published test vectors, in optimised and debug builds alike. Byte-by-byte loops run in chunks, so a debug build hashes any size without running out of stack, and an optimised one as fast as the benchmark's loop. Golden testhash_module, a section in docs/std.md and the tutorial (chapter 16), and man pages (mimic man hash).- The corpus reaches 130: 41 more everyday algorithms in Mimic, C and Rust, each checked against an independent reference: numbers (
gauss,millerrabin,coprime,totient,partitions,fibmod,catalan,polyeval,bigfact), simulations (shuffle,randwalk,ising,sandpile,rule110,traffic,langton), puzzles (tsp,sudoku,knight,matchain), graphs (mst,bellman,bipartite,flood,maze), data structures (lru,rangemin,intervals,bitset), text (roman,soundex,wordwrap,xmltags,markdown,template,lisp), hashing and ciphers (crc64,sha1,chacha20),base32anddct. On one core on the M-series Mac most are within 1-2× of C (intervals,mst,bellman,ising,partitions,sha1andbase32faster); the slowest are text built piece by piece (markdown4.9×,xmltags4.4×,soundex3.6×,roman3.5×),tsp4.2× (the table rewritten for each set size),sudoku3.8× (a new board for each placement) andflood3.4× (a pair made for each neighbour). Writing them found the fixes above, and gaps recorded in docs/gaps.md. - The corpus, more text:
zalgo(Z-algorithm),manacher(Manacher's palindromes) andanagram(anagram classes), in Mimic, C and Rust, checked against Python. On one core on the M-series Mac, against C:manacher1.9×,zalgo3.2× (sequential passes thatputinto a list held by a record: 0.4.3),anagram6.5× (half a million words built letter by letter as strings). - The corpus, geometry:
hull(convex hull by monotone chain),pip(point in polygon by ray casting) andsegments(segment intersection, all pairs), in Mimic, C and Rust, in exact integer arithmetic, checked against Python. On one core on the M-series Mac, against C:hull0.75× (sorting one number per point),segments1.1×,pip1.3×; on all cores 2.2–4.5× faster than C. Found on the way:(a > y) != (b > y)is refused as a chained comparison, and a long condition cannot be split over lines except inside parentheses (docs/gaps.md). - The corpus, more parsing, and servers:
numparse,semverandini(checked against Python,iniagainstconfigparser), and two servers with their own load generators:http_route(a JSON API with path parameters and 404s) andhttp_echo(POST bodies answered in upper case), in Mimic, C and Rust (hyper). On one core on the M-series Mac, against C:http_echo0.96×,http_route1.6×,numparse2.4×,semver3.2×,ini4.0× (eachsliceandtrimmakes a new string: docs/gaps.md, 0.4.12); on all cores both servers match or beat the single-threaded C server. - The corpus, more compression and hashing:
varint(zigzag LEB128 deltas),bitpack(13-bit values in 64-bit words),lzw,xxhash64,md5andsiphash(SipHash-2-4), in Mimic, C and Rust, checked against Python (xxhash,hashlib, and the SipHash paper's test vector). On one core on the M-series Mac, against C:bitpack1.8×,md51.4×,xxhash641.6×,varint3.9×,lzw3.8×,siphash22× (its rounds return the state as a tuple, which is allocated: docs/gaps.md, 0.4.3).bitpackpacks and unpacks as one parallel map each; the hashes loop with a function that calls itself, which is many times faster than asettleover a tuple. Found on the way: deep recursion through a function that takes a list or returns a tuple can still overflow the native stack past ~50,000 levels, with no message (docs/gaps.md); a type name for a tuple is not accepted. - The corpus, dynamic programming:
lcs(longest common subsequence, each row one map and onetrail(⌈)),coins(ways to make change) andlis(longest increasing subsequence by patience sorting), in Mimic, C and Rust, checked against Python. On one core on the M-series Mac, against C:lis0.7×,lcs1.5×,coins4.3× (a step thatputs into a list held by a record goes through the record each time: docs/gaps.md, 0.4.3). Found on the way:gatherwith a lambda goes through the runtime one boxed pair at a time (docs/gaps.md, 0.4.1). - The corpus, sorting and searching:
radix(LSD radix sort),bsearch(binary search, lower bounds) andselect(quickselect), in Mimic, C and Rust, checked against numpy. On one core on the M-series Mac, against C:bsearch0.9×,select1.6×,radix4.8× (everyputof its placing pass is a call into the runtime: docs/gaps.md, 0.4.3). A bottom-up merge sort is written but waits for lists built from pieces to keep their type (docs/gaps.md). - The corpus, images:
histeq(histogram equalization),rotate(90° turns),dither(Floyd–Steinberg error diffusion) andintegral(a summed-area table and 8,000,000 box sums), in Mimic, C and Rust, checked against Python (numpy for all butdither). On one core on the M-series Mac, against C:histeq1.7×,rotate1.6×,dither2.2×,integral1.5×; on all cores each is faster than C (frames, rows and boxes run in parallel). Found on the way: a lambda kept in aletand called in a hot loop is 15–40× slower than the same named function (docs/gaps.md, for 0.4.1). - The corpus, data structures:
bloom,hashmap,heapandfenwick, in Mimic, C and Rust, checked against Python. Each updates a list...
Mimic 0.4.0-preview.2
A preview of the next version: not a stable release. Install it with mimic upgrade --preview.
Stage 0.4.0, the measuring stick, so far (0.4.0-preview.2): a benchmark corpus of 54 everyday algorithms (hashing, parsing, graphs, text, interpreters, compression, numbers and simulations), each in Mimic, C and Rust; the machine's limits; and a speed gate that fails CI on a slowdown. The corpus already found bugs and the gaps the rest of stage 0.4 closes.
Changed
- The speed gate times short benchmarks longer: each side runs until it has run for a second (at most 30 runs) before the best time is taken. Benchmarks of 50–130 ms raised false alarms of 6–22% with the best of 3.
- The gate's noise is measured as the gate compares:
bench/run.py --noisenow runs the gate's comparison with the same compiler on both sides; a benchmark too noisy for the 25% limit on a platform is reported there, not gated. (The first noise data, ratios to C across whole rounds, overstated it, and a preview's identical compiler failed the gate ontreeandui.) - Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (
bench/http/load/main.rs).
Added
- The 0.4.0 corpus, text:
levenshtein,kmp,utf8,aho(Aho-Corasick),diff(Myers),trieandwordfreq, in Mimic, C and Rust with the same algorithms, checked against Python. Work that splits into independent pieces runs close to C on all cores (kmp1.07×), while one byte or cell at a time stays 22–36× on one core. - The 0.4.0 corpus, numbers and simulations:
sieve,montecarlo,blackscholes,heat,life,fft,kmeansandbigmul, in Mimic, C and Rust with the same algorithms, checked against Python (numpy, or its own big integers). Arithmetic over independent elements is at or near C on one core (montecarlo1.0×,blackscholes1.18×,kmeans0.84×) and several times faster on all cores. Writing them found four gaps (docs/gaps.md): a record used inside¨is retained and released for every element (20× the CPU time on all cores),puton[u8]copies,math::piwithout()passes the checker, and an FFT built from¨stages is 6× C. - The 0.4.0 corpus, graphs:
bfs,components,topoandpagerank, in Mimic, C and Rust with the same algorithms, checked against Python. Writing them found two more ways an update is copied instead of made in place (docs/gaps.md): anifinside{ … with … }(118 s against 7 s) and a helper that changes an array its caller's record holds. - The 0.4.0 corpus, interpreters and regex:
regex(a Thompson NFA engine, checked against Python'sre),brainf(a Brainf**k interpreter) andvm(a stack bytecode VM), in Mimic, C and Rust. An interpreter's loop is 27–54× C today (docs/gaps.md). - The speed gate:
bench/run.py --gate BEFOREbuilds every benchmark with the changed compiler and with the one it changes, times them in turns on the same machine, and fails on a slowdown beyond that benchmark's tolerance (twice its noise measured on GitHub's machines, 3–25%, frombench/noise/) in 2 of 3 measurements. The bench workflow runs it on release pull requests, nightly ondev, and on pull requests that change what is measured, and checks each time that the compiler without its optimizer (MIMIC_DEBUG_DISABLE=optimizer) fails it. - The 0.4.0 corpus, hashing:
crc32,adler32,fnv1a,murmur3,xxhash32andsha256benchmarks in Mimic, C and Rust, checked against independent references. They show sequential passes over arrays 13–57× slower than C and SHA-256 170× (docs/gaps.md, with the 0.4 steps that fix them), and that Mimic has nofold. - The 0.4.0 corpus, parsing:
csv,expr,tokenize,urlandhttp_parse, checked against Python'scsv,eval,reandurllib. Parsing that splits into independent pieces runs in parallel and is at or near C's time on all cores (csv0.90×,expr0.95×); scanning characters one at a time is 25× C on one core (docs/gaps.md). - The 0.4.0 corpus, compression:
rle,base64andlz77, checked against Python (base64, and reference implementations). They show where growing a list in a loop copies it: the LZ77 decoder is 476× C (docs/gaps.md).rlefoundflattenquadratic (fixed above).huffmanandbwtfollow:huffmanshowed asettlestep written as a lambda copying its state where a named step function changes it in place (37 s against 2.1 s). - The share of the machine:
bench/machine/measures the peak floating-point rate and the memory bandwidth, on one core and on all, and benchmarks that declare their work (meta.json: matmul, mandelbrot, prefix_sum so far) also show what share of that limit each version reached (bench/run.py --machinemeasures again). bench/run.py --jsonwrites a run's times as JSON, and--noise Nruns everything N times unchanged and records how much each ratio to C varies on the machine (bench/noise/<platform>.json; the bench workflow'snoiseinput runs it on GitHub's machines). It is the first part of 0.4.0: the speed gate's tolerances come from this measured noise.
Fixed
- Builds running at once could fail with
redefinition of 'MIM_UI_JS': each rewrote the runtime's cached sources while others compiled from them, and the C compiler, which tells files apart by inode, could take one file for another once an inode was reused. The sources of each runtime version are now written once, into a directory moved into place whole. --previewpicks only a release with files: the releases feed it reads also lists a tag whose release is still being built, so during the minutes a preview was building,mimic upgrade --previewchose it and failed with a 404. It now takes the newest preview or stable release whose files are there.- No release without its files: a release is now published only after its binaries and checksums are uploaded. Before, for a moment a new release could be the latest with nothing to download, and the install command failed with "Not Found" (the install scripts' check on the 0.3.18 release did). That check now runs when the release workflow finishes; it never ran on a release before.
- Builds at the same time no longer spoil the runtime: files Mimic writes "atomically" (through a temporary file) used a temporary name per process, so two threads of one build writing the same runtime file shared it and could interleave their bytes; CI saw
redefinition of 'MIM_UI_JS'once. Every write now has a temporary name of its own, the runtime's object file too. flattenis linear: it joined the lists two at a time, copying the growing result again for every list, so flattening many small lists was quadratic (200,000 pairs: about a minute; now milliseconds). Each element is now placed once, in parallel. The same in theuimodule. Found by the 0.4.0 benchmark corpus.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.0-preview.2-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.0-preview.2-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.0-preview.2-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.4.0-preview.1
A preview of the next version: not a stable release. Install it with mimic upgrade --preview.
Stage 0.4.0, the measuring stick, so far (0.4.0-preview.1): a benchmark corpus of everyday algorithms, each in Mimic, C and Rust; the machine's limits; and a speed gate that fails CI on a slowdown. The corpus already found two bugs and the gaps the rest of stage 0.4 closes.
Changed
- Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (
bench/http/load/main.rs).
Added
- The speed gate:
bench/run.py --gate BEFOREbuilds every benchmark with the changed compiler and with the one it changes, times them in turns on the same machine, and fails on a slowdown beyond that benchmark's tolerance (twice its noise measured on GitHub's machines, 3–25%, frombench/noise/) in 2 of 3 measurements. The bench workflow runs it on release pull requests, nightly ondev, and on pull requests that change what is measured, and checks each time that the compiler without its optimizer (MIMIC_DEBUG_DISABLE=optimizer) fails it. - The 0.4.0 corpus, hashing:
crc32,adler32,fnv1a,murmur3,xxhash32andsha256benchmarks in Mimic, C and Rust, checked against independent references. They show sequential passes over arrays 13–57× slower than C and SHA-256 170× (docs/gaps.md, with the 0.4 steps that fix them), and that Mimic has nofold. - The 0.4.0 corpus, parsing:
csv,expr,tokenize,urlandhttp_parse, checked against Python'scsv,eval,reandurllib. Parsing that splits into independent pieces runs in parallel and is at or near C's time on all cores (csv0.90×,expr0.95×); scanning characters one at a time is 25× C on one core (docs/gaps.md). - The 0.4.0 corpus, compression:
rle,base64andlz77, checked against Python (base64, and reference implementations). They show where growing a list in a loop copies it: the LZ77 decoder is 476× C (docs/gaps.md).rlefoundflattenquadratic (fixed above).huffmanandbwtfollow:huffmanshowed asettlestep written as a lambda copying its state where a named step function changes it in place (37 s against 2.1 s). - The share of the machine:
bench/machine/measures the peak floating-point rate and the memory bandwidth, on one core and on all, and benchmarks that declare their work (meta.json: matmul, mandelbrot, prefix_sum so far) also show what share of that limit each version reached (bench/run.py --machinemeasures again). bench/run.py --jsonwrites a run's times as JSON, and--noise Nruns everything N times unchanged and records how much each ratio to C varies on the machine (bench/noise/<platform>.json; the bench workflow'snoiseinput runs it on GitHub's machines). It is the first part of 0.4.0: the speed gate's tolerances come from this measured noise.
Fixed
- No release without its files: a release is now published only after its binaries and checksums are uploaded. Before, for a moment a new release could be the latest with nothing to download, and the install command failed with "Not Found" (the install scripts' check on the 0.3.18 release did). That check now runs when the release workflow finishes; it never ran on a release before.
- Builds at the same time no longer spoil the runtime: files Mimic writes "atomically" (through a temporary file) used a temporary name per process, so two threads of one build writing the same runtime file shared it and could interleave their bytes; CI saw
redefinition of 'MIM_UI_JS'once. Every write now has a temporary name of its own, the runtime's object file too. flattenis linear: it joined the lists two at a time, copying the growing result again for every list, so flattening many small lists was quadratic (200,000 pairs: about a minute; now milliseconds). Each element is now placed once, in parallel. The same in theuimodule. Found by the 0.4.0 benchmark corpus.
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.4.0-preview.1-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.4.0-preview.1-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.4.0-preview.1-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.
Mimic 0.3.18
Release channels: previews of the next version and nightly builds, alongside stable releases.
Added
- Release channels:
mimic upgrade --previewinstalls the newest preview of the next version (or stable, when it is newer) andmimic upgrade --nightlythe nightly build of the development branch; the channel is remembered, so latermimic upgrades stay on it, and--stablegoes back. The install commands take the same options (sh -s -- --preview,$env:MIMIC_CHANNEL = "nightly"on Windows). Stable stays the default, and previews and nightlies never reach the install command or the website unless asked for.
Changed
- How Mimic is developed: work comes together on a
devbranch through reviewed pull requests,mainholds releases only, and a nightly build and weekly previews keep each long step visible (docs/versions.md).
Install
Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.
| System | File | Install | Also needed |
|---|---|---|---|
| Windows x86_64 (10, 11) | mimic-0.3.18-windows-x86_64.zip |
Double-click install.cmd |
Nothing: Windows programs are linked with the MinGW-w64 inside mimic. |
| macOS Apple silicon | mimic-0.3.18-macos-arm64.tar.gz |
./install.sh |
The Xcode Command Line Tools (xcode-select --install), for the macOS SDK. |
| Linux x86_64 | mimic-0.3.18-linux-x86_64.tar.gz |
./install.sh |
glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else. |
On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:
powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.
Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.
- macOS: the script clears the download quarantine. If you copy
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.