MIMIC

Learn Mimic

Mimic is a compiled language for programs that should be fast without effort. Its main traits:

  • Array-based. Whole arrays are values. prices × 1.2 updates every price at once.
  • Parallel by default. You never mark code as parallel. The compiler runs everything that can safely run at the same time across all your cores.
  • Memory safe. It has no garbage collector and no manual freeing. Values are immutable unless you say mut.
  • No loops. Iteration is written with array operations and a handful of loop words.
  • One binary. mimic contains its own LLVM, Clang and linker. It builds native programs for macOS, Linux, Windows, iOS, WebAssembly and more, with nothing else installed.

How to use this guide

The chapters build on each other, so read them in order the first time. Every example that shows output is a complete program you can paste into a file and run with mimic run file.mim. The outputs shown are checked against the real compiler.

# Chapter You will learn
1 Getting started Install, your first program, mimic run
2 Values and functions Numbers, let, fn, if, string interpolation
3 Arrays and glyphs Array operations, glyphs ↔ words, pipelines
4 No loops ¨, gather, trail, evolve, settle, arms, recursion
5 Records, unions and match Your own types and pattern matching
6 Strings, lists and maps The standard library
7 Errors without exceptions Option, Result, let … else
8 Functions as values Lambdas, closures, operators as values
9 Generics Option[T], fn first[T], generic types
10 Parallel by default What runs in parallel, and why it is safe
11 Projects and modules mimic create, mim.mim, modules, pub, libraries
12 Calling C extern "C", importing headers, callbacks, declaring effects
13 Building for other platforms --target, --cpu, mimic targets
14 Tooling check, explain, --fix, JSON diagnostics
15 Arrays in depth Matrices, reshape, transpose, m[i, j], fast matrix products
16 Files and the outside world Arguments, environment, stdin, files, directories, paths, time, random numbers, running programs
17 Networking The http, ws and tcp modules: HTTPS, servers, routes, WebSockets, sockets
18 JSON json::encode, json::decode[T] into your records, raw strings, a JSON API
19 Tasks and channels Background tasks, chan::new[T](), a worker, a WebSocket chat room
20 Interfaces view(state), update(state, message), ui::run in the browser, a to-do list

For the complete rules, see the reference in docs/: syntax, standard library, FFI, targets and CLI.

From docs/tutorial/index.md in the Mimic repository.