{"id":46092658,"url":"https://github.com/miri-lang/miri","last_synced_at":"2026-05-08T00:04:25.875Z","repository":{"id":341253180,"uuid":"84775997","full_name":"miri-lang/miri","owner":"miri-lang","description":"A modern, GPU-first, statically-typed, compiled programming language designed for balancing high performance and safety in the age of Generative AI","archived":false,"fork":false,"pushed_at":"2026-02-28T18:35:27.000Z","size":1856,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-28T20:31:49.731Z","etag":null,"topics":["compiler","cranelift","gpu","gpu-programming","llvm","miri","programming-language"],"latest_commit_sha":null,"homepage":"https://miri-lang.org","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miri-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2017-03-13T02:32:50.000Z","updated_at":"2026-02-28T18:41:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/miri-lang/miri","commit_stats":null,"previous_names":["miri-lang/miri"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/miri-lang/miri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miri-lang%2Fmiri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miri-lang%2Fmiri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miri-lang%2Fmiri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miri-lang%2Fmiri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miri-lang","download_url":"https://codeload.github.com/miri-lang/miri/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miri-lang%2Fmiri/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29977966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","cranelift","gpu","gpu-programming","llvm","miri","programming-language"],"created_at":"2026-03-01T18:00:54.393Z","updated_at":"2026-05-08T00:04:25.856Z","avatar_url":"https://github.com/miri-lang.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Miri Programming Language\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"banner.png\"/\u003e\n\u003c/p\u003e\n\n**A modern, GPU-first, statically-typed, compiled programming language designed for balancing high performance and safety in the age of Generative AI.**\n\nMiri is designed for agentic engineering, where humans define intent and AI fills in safe, verifiable, high-performance implementations.\n\n## Current State (v0.3.0-beta.1)\n\nMiri has reached its first Beta release. Building on the multi-file module system from Alpha 4, this release closes an important milestone - **Memory Safety (Perceus+)** - delivering value semantics, compiler-inferred ownership, optimized reference counting, copy-on-write collections, escape-based use-after-move analysis, and `out`-mode parameters. The programmer's only memory-related concept is `out`; everything else is inferred by the compiler.\n\n**Working Features:**\n- **Primitives \u0026 Variables**: `int`, `float`, `bool`, `String` via `let` (immutable) and `var` (mutable).\n- **Functions**: Typed parameters and returns, named arguments. `out` parameters for in-place mutation (`fn inc(n out int): n = n + 1`).\n- **Control Flow**: `if/else`, `unless`, `while`, `until`, `do-while`, `forever`, `for..in`.\n- **Pattern Matching**: `match` with guards, destructuring, and or-patterns.\n- **Structs**: Named fields, construction with named arguments, field access.\n- **Enums**: Variants with associated data, pattern matching with extraction.\n- **Tuples**: Construction, index access, destructuring in match.\n- **Collections**: `Array` (fixed-size `[T; N]`), `List` (dynamic `[T]`), `Map` (`{K: V}`), `Set` (`{T}`) — all with full method APIs and **value semantics enforced by Copy-on-Write**.\n- **Option Types**: `Type?`, `None`, `Some`, `if let` unwrapping.\n- **Type Aliases**: `type ID is String`.\n- **Memory Safety (Perceus+)**: Compiler-inferred ownership with element-level reference counting, automatic IncRef/DecRef placement, RC elision on linear flow, and Copy-on-Write for collections and strings. No memory annotations required (only `out`).\n- **Use-After-Move Checking**: Resource types (any type defining `fn drop(self)`) are tracked strictly at every scope. Managed types (collections, strings, classes) are tracked at top level immediately and inside function bodies via escape inference — multi-hop diagnostic chains explain *why* a value is consumed (which call → which sink).\n- **Cloneable Trait \u0026 `.clone()`**: Built-in `Cloneable` trait with deep-copy semantics. All managed types implement it; user-defined classes get auto-generated `__clone_TypeName` helpers.\n- **User-Defined Destructors**: `fn drop(self)` on a struct or class declares a resource type. Drop fires automatically at scope exit before recursive field decref and free (RC=0 → user `drop` → field DecRef → free).\n- **Compilation Pipeline**: Full frontend (Lexer, Parser, Type Checker), MIR Lowering with 5 optimization passes, and Native Codegen (via Cranelift).\n- **Classes**: Full OOP with constructors (`init`), methods, field access, visibility modifiers (`private`, `protected`, `public`), inheritance with complete field layout, `super` method calls, and abstract class/method enforcement.\n- **Traits**: Declare shared interfaces with abstract and concrete (default) methods. Classes implement one or more traits; trait inheritance chains are fully validated by the type checker.\n- **Closures**: Non-capturing and capturing lambdas compiled to native code. Captures by value; closure represented as a fat pointer `(fn_ptr, env_ptr)`. Captured values are RC-tracked and released when the closure is dropped.\n- **Generics**: Generic function and generic struct/class monomorphization. Specialized copies emitted per unique type instantiation.\n- **Virtual Dispatch**: Vtable generation for class hierarchies; runtime method dispatch for polymorphic variables and trait objects.\n- **Multi-File Projects**: Programs can span multiple `.mi` files. The compiler discovers, parses, and links all files in a project automatically.\n- **Module System**: `use local.*` resolves to project files, `use system.*` resolves to stdlib. Supports selective imports (`use system.io.{println}`) and module aliasing (`use system.math as M`).\n- **Cross-Module Visibility**: `public`, `private`, and `protected` modifiers are enforced across module boundaries. Private symbols are invisible to importers.\n- **Namespace Collision Detection**: Conflicting names across imports and local declarations are detected with clear error messages and suggestions.\n- **Circular Dependency Detection**: Circular import chains are detected and reported with clear diagnostics.\n\n## Quick Start\n\n### Hello World\n\n```miri\nuse system.io\n\nfn main()\n    println(\"Hello, World!\")\n```\n\n### Variables\n\n```miri\nlet x = 10              // Immutable integer\nvar y = 20              // Mutable integer\ny = 30                  // OK\nlet name String = \"Miri\" // Explicit type\n```\n\n### Functions\n\n```miri\nfn add(a int, b int) int\n    a + b\n\nlet result = add(5, 10)\n```\n\n### Structs\n\n```miri\nuse system.io\n\nstruct Point\n    x int\n    y int\n\nfn offset(p Point, dx int, dy int) Point\n    Point(x: p.x + dx, y: p.y + dy)\n\nfn main()\n    let p = Point(x: 1, y: 2)\n    let q = offset(p, 10, 20)\n    println(f\"{q.x}, {q.y}\")\n```\n\n### Enums with Data\n\n```miri\nuse system.io\n\nenum Shape\n    Circle(float)\n    Rect(float, float)\n\nfn area(s Shape) float\n    match s\n        Shape.Circle(r): 3.14 * r * r\n        Shape.Rect(w, h): w * h\n```\n\n### Collections\n\n```miri\nuse system.io\nuse system.collections.list\nuse system.collections.map\n\nvar items = List([1, 2, 3])\nitems.push(4)\n\nlet scores = {\"Alice\": 95, \"Bob\": 87}\nprintln(f\"{scores[\"Alice\"]}\")\n```\n\n### Classes\n\n```miri\nuse system.io\n\nclass Animal\n    protected name String\n\n    fn init(n String)\n        self.name = n\n\n    fn speak()\n        println(f\"I am {self.name}\")\n\nclass Dog extends Animal\n    fn speak()\n        super.speak()\n        println(\"Woof!\")\n\nfn main()\n    let d = Dog(n: \"Rex\")\n    d.speak()\n```\n\n### Closures\n\n```miri\nuse system.io\n\nfn main()\n    var x = 10\n    let add = fn(n int) int: x + n\n    println(f\"{add(5)}\")   // 15\n```\n\n### Generics\n\n```miri\nuse system.io\n\nfn identity\u003cT\u003e(x T) T\n    x\n\nstruct Wrapper\u003cT\u003e\n    value T\n\nfn main()\n    println(f\"{identity(42)}\")\n    println(f\"{identity(\"hello\")}\")\n    let w = Wrapper\u003cint\u003e(value: 99)\n    println(f\"{w.value}\")\n```\n\n### Memory Safety in Practice\n\nValue semantics are enforced — assignment is a logical copy, mutation never aliases:\n\n```miri\nuse system.io\nuse system.collections.list\n\nfn main()\n    let a = List([1, 2, 3])\n    var b = a            // copy-on-write share\n    b.push(4)            // CoW fires: b becomes independent\n    println(f\"{a.length()} {b.length()}\")   // 3 4\n```\n\n`out` is the one explicit memory annotation:\n\n```miri\nuse system.io\n\nfn inc(n out int)\n    n = n + 1\n\nfn main()\n    var x = 41\n    inc(x)\n    println(f\"{x}\")      // 42\n```\n\nResource types (those defining `fn drop(self)`) are tracked strictly — the compiler refuses to let you use one after it has been consumed:\n\n```miri\nstruct File\n    handle int\n    fn drop(self)\n        // close the underlying handle\n        ...\n\nfn archive(f File)\n    // ...\n\nfn main()\n    let f = File(handle: 1)\n    archive(f)\n    archive(f)           // compile error: 'f' was consumed by 'archive'\n```\n\n### Traits\n\n```miri\nuse system.io\n\ntrait Speakable\n    fn speak()\n\ntrait Describable extends Speakable\n    fn describe()\n        println(\"I am an animal\")\n\nclass Dog implements Describable\n    fn speak()\n        println(\"Woof!\")\n\nfn main()\n    let d = Dog()\n    d.speak()\n    d.describe()\n```\n\n### Multi-File Projects\n\n```miri\n// models/user.mi\nuse system.io\n\nclass User\n    public name String\n\n    fn init(n String)\n        self.name = n\n\n    public fn greet()\n        println(f\"Hello, {self.name}\")\n```\n\n```miri\n// main.mi\nuse local.models.user\n\nfn main()\n    let u = User(n: \"Alice\")\n    u.greet()\n```\n\n### Module Aliasing\n\n```miri\nuse system.collections.list as L\n\nfn main()\n    var items = L.List([1, 2, 3])\n```\n\n### Option Types\n\n```miri\nuse system.io\n\nfn find(name String?)\n    if let Some(s) = name\n        println(f\"Found: {s}\")\n```\n\n### Control Flow\n\n```miri\nif x \u003e 10\n    print(\"Big\")\nelse\n    print(\"Small\")\n\nfor i in 1..5\n    print(i)\n```\n\n### Pattern Matching\n\n```miri\nmatch x\n    1: print(\"One\")\n    2 | 3: print(\"Two or Three\")\n    x if x \u003e 10: print(\"Large\")\n    _: print(\"Other\")\n```\n\n## Architecture\n\nMiri follows a standard compiler pipeline:\n\n```text\nSource(s) → Lexer → Parser → AST → Type Checker → MIR → Codegen → Object File → Linker → Executable\n```\n\nThe `Pipeline` struct in `src/pipeline.rs` orchestrates:\n\n1. **Discovery** — Finding all `.mi` files in the project, resolving `use local.*` and `use system.*` imports\n2. **Frontend** — Lexing and Parsing (per file)\n3. **Script Wrapping** — Auto-wrapping top-level statements into `main` if needed\n4. **Analysis** — Type checking with cross-module visibility enforcement\n5. **Lowering** — Converting AST to MIR\n6. **Backend** — Cranelift (default) code generation\n7. **Linking** — System linker (`cc`) produces the final binary\n\n### Backends\n\n- **Cranelift** (`src/codegen/cranelift/`) — Default backend. Fast compilation for development.\n- *(Future)* **LLVM** (`src/codegen/llvm/`) — Intended for optimized production builds.\n\n## Repository Layout\n\n```bash\nsrc/\n├── ast/          # Syntax tree definitions\n├── cli/          # Command-line interface\n├── codegen/      # Backend implementations (Cranelift)\n├── error/        # Error types and formatting\n├── lexer/        # Source tokenization\n├── mir/          # IR definitions and lowering\n├── parser/       # Parsing logic\n├── runtime/      # Scaffolding and intrinsics\n├── stdlib/       # Standard Library (system.*)\n├── type_checker/ # Type inference and validation\n└── pipeline.rs   # Main compiler driver\n```\n\n## Building from Source\n\nMiri is written in Rust. Build with a stable Rust toolchain:\n\n```bash\nmake build        # Build compiler + all runtime crates (debug)\nmake release      # Build compiler + all runtime crates (release)\n```\n\nThe release binary will be available at `target/release/miri`.\n\n## Running Tests\n\nRun the full test suite across the compiler, standard library, and all runtime crates:\n\n```bash\nmake test\n```\n\n## Linting \u0026 Formatting\n\n```bash\nmake lint         # Check formatting + clippy (compiler + runtimes)\nmake format       # Auto-format all code (compiler + runtimes)\n```\n\n## Contributing\n\nWe welcome contributions! Please read our [Contributing Guide](CONTRIBUTING.md) for details on code style, testing requirements, and the submission process.\n\n### Contributors\n\n- Viacheslav Shynkarenko aka Slavik Shynkarenko (maintainer)\n\n## License\n\n[Apache-2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiri-lang%2Fmiri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiri-lang%2Fmiri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiri-lang%2Fmiri/lists"}