Get Started

mu is small enough to learn in an afternoon and complete enough to build with: run the REPL, compile standalone binaries with no toolchain installed, and cross-compile them for another architecture.

Before you install anything

play.mu-lang.dev runs mu in the browser, with every example from the repository already loaded. It is the fastest way to find out whether you like the language — try hello, closures, or exact decimals — and it takes a shareable link, so a question about mu can travel as a program.

The playground refuses programs that open sockets, start processes or call into shared libraries. That is a property of that deployment, not of the language: locally, mu has no such limit.

Requirements

Quickstart

  1. Clone the repository:
git clone https://git.mills.io/prologic/mu.git
cd mu
  1. Build the host:
go build -o ./mu ./cmd/mu
  1. Run the REPL:
./mu

Type help() at the prompt for the keywords, builtins and stdlib modules available, and help(name) for anything in particular:

µ> help(len)
Builtin len

  len(value) returns the length of a string, list, map, or buffer.

help() answers from the running program, so it can only describe what is already loaded. To look something up without one, build mu-doc:

go build -o ./mu-doc ./cmd/mu-doc

./mu-doc                # every builtin, prelude name and module
./mu-doc sockets        # a module
./mu-doc strings.split  # one declaration
./mu-doc -k parse       # search names and documentation

It is the same documentation as doc.mu-lang.dev, because both are extracted from the library’s source, and it works offline.

  1. Try a hello program:
fn main() {
  print("Hello World!")
}

main()

Next steps

CLI essentials

Tooling helpers

Compiling mu with mu

The compiler in selfhost/ is written in mu, and you can use it the same way you use the Go host:

./mu selfhost/mu.mu hello.mu            # run through the mu-written VM
./mu selfhost/mu.mu -B -o hello hello.mu # compile with the mu-written backend
sh scripts/bootstrap.sh                  # rebuild it with itself, and check the fixpoint

Explore examples

References

Design goals