Skip to content

Hello! 👋 My name is Nathan Weir. This is a fun personal project for using AI to build a bespoke, domain-specific programming language. It is not a serious, professional project. This site and the language itself are largely generated via Claude Code. If you find yourself programming with Weir, have fun - but use at your own risk!

Introduction

Weir is a statically typed, Lisp-family programming language that compiles to native code via Cranelift. It’s designed for fast iteration in small-scale game development — combining the expressive power of S-expressions with a modern type system and function-level live reloading.

A weir is a low dam built across a river to control water flow. It doesn’t block the river — it guides it. Water still flows freely, but the weir shapes where it goes, prevents flooding, and creates predictable behavior downstream.

This is the language’s design philosophy in physical form:

  • Controls flow without stopping it — guard rails that prevent bugs without preventing expressiveness
  • An engineering structure, not a wall — practical, purposeful constraints that make the system more useful, not more restrictive
  • Predictable downstream behavior — static types, exhaustive matching, and clear error handling mean you know what to expect
  • The water still flows — Lisp’s expressive power, live reloading, and fast iteration are preserved

The language actively prevents the developer from inadvertently causing bugs through trivial misuse. If the design leans more hand-holdy than typical, that’s acceptable — within reason.

  • Hygienic macros over unhygienic — prevent accidental variable capture
  • Static types over dynamic — catch errors before runtime
  • Immutable by default — prevent accidental mutation and aliasing bugs
  • Exhaustive pattern matching — compiler errors on unhandled cases
  • Arena escape prevention at compile time — no dangling references to freed memory
  • Safe defaults with explicit opt-out over unsafe defaults with opt-in

The primary use case is game development with live iteration. Write code → see it running → adjust → see the adjustment. Compilation speed in dev mode, clear error messages, and immediate feedback matter more than squeezing out the last 5% of release-build performance.

Investing in type system expressiveness (generics, typeclasses, associated types) reduces the need for complex macros. A simpler, purely syntactic macro system becomes more viable when the type system carries more weight.

Weir draws inspiration from several languages:

InspirationWhat Weir Borrows
Common LispS-expression syntax, interactive development, keywords
CarpFunction type syntax (Fn [args] return), inline type annotations
CoaltonTypeclasses in S-expression syntax, HKT support, .field accessors
HaskellTypeclass design, algebraic data types, exhaustive matching
RustLocal type inference, coherence rules, memory safety philosophy
ErlangHot code loading model, start-from-source (no image persistence)

Weir is implemented in Rust with:

  • Cranelift for dev-mode JIT compilation (optimized for fast compile times)
  • AOT compilation via Cranelift + system linker for release binaries
  • Tracing GC (mark-and-sweep) with opt-in arena allocation
  • LSP server for editor integration from day one
  • Tree-sitter grammar for syntax highlighting