Skip to content

musi-lang/musi

Musi

A programming language with a type system, functional features, and a stack-based bytecode VM.

Warning

Musi is v0.1.0-rc1. The language, tooling, and standard library will have breaking changes. Do not use it for anything you can't afford to rewrite.

What Musi Is

Musi source files use the .ms extension. The toolchain has two binaries:

Binary What it does
musi Universal driver - run, check, build, test, format, lint, manage projects
msc Standalone compiler - type-check and compile without the VM

You will mostly use musi. The msc binary is for compiler-only workflows (CI type-checking, producing .seam bytecode without running it).

Prerequisites

1. Rust 1.87 or newer

# install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# or update
rustup update stable

# verify
rustc --version

2. libffi

Musi uses libffi for its foreign function interface.

macOS:

brew install libffi

Ubuntu / Debian:

sudo apt install libffi-dev

Fedora / RHEL:

sudo dnf install libffi-devel

3. Git

You probably already have this. If not: https://git-scm.com/downloads

Install from Source

There are no pre-built binaries yet.

git clone https://github.com/musi-lang/musi.git
cd musi
cargo build --release

Binaries land in ./target/release/:

  • musi (toolchain driver)
  • msc (standalone compiler)
  • msc_lsp (LSP server)

Add to your PATH:

export PATH="/path/to/musi/target/release:$PATH"

Quick Start

musi new hello
cd hello

This creates:

hello/
  musi.json     project manifest
  index.ms      source file
  .gitignore

Look at the generated index.ms:

import "@std/rt" as rt;

rt.writeln("hello, world!");

Run it:

musi run

Other commands:

musi check              # type-check without running
musi build              # compile to .seam bytecode
musi exec index.seam    # run compiled bytecode directly
musi test               # discover and run *.test.ms files
musi fmt                # format source files
musi lint               # lint source files

A Taste of the Language

TODO

Project Structure

Crate Role
msc Compiler library + CLI
musi Toolchain driver CLI
msc_lsp LSP server
msc_shared Spans, source database, interner, diagnostics
msc_lex Lexer
msc_ast AST node types
msc_parse Parser
msc_sema Semantic analysis / type-checker
msc_resolve Module resolution
msc_emit Bytecode emitter
msc_bc Bytecode format definitions
msc_vm Bytecode interpreter / VM
msc_builtins Standard library runtime + FFI
msc_manifest musi.json parser

Editor Support

The msc_lsp binary is built alongside the compiler. Point your editor's LSP client at it. A VS Code extension is in development at tools/vscode/.

Testing

cargo test -p msc_parse        # test a specific crate
cargo clippy -p msc_parse      # lint a specific crate
musi test                      # run Musi stdlib tests

Avoid cargo test --workspace on machines with less than 16 GB of free RAM.

See CONTRIBUTING.md for the full development guide.

Contributing

Contributions welcome. See CONTRIBUTING.md for workflow, coding guidelines, and the PR checklist.

Code of Conduct

All contributors are expected to follow the Code of Conduct.

Star History

Star History Chart

License

MIT OR Apache-2.0 - see LICENSE for details.