Repository navigation
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.