Maxon 发布由 AI 编写的静态类型编译型编程语言
maxon-lang/maxon
Maxon 发布一门静态类型、编译型编程语言,编译器、标准库和文档均由 AI 编码智能体编写,自带从零实现的原生后端,直接编译为独立可执行文件,不依赖 LLVM、虚拟机、汇编器或链接器。
You Aren't Going To Write It.
Maxon makes a bet: the AI writes the code, so the code has to answer for itself.
Maxon is a statically-typed, compiled programming language with a from-scratch native backend — written by AI, for AI. The compiler, standard library, and documentation were all authored by AI coding agents.
Because the AI writes the code, Maxon optimizes for review, not keystrokes. Where another language is terse, Maxon is explicit: every constraint is stated, every block is named, nothing is implicit to puzzle out later. Whatever you go looking for — a bound, a failure path, where a block ends — is on the page rather than reconstructed. The same explicitness that makes it checkable makes it hard to get wrong — exactly the property you want when a model is generating the code.
maxon.dev · Documentation · Examples · Discussions
typealias Port = int(0 to 65535)
function main() returns ExitCode
let port = 8080 as Port
print("listening on {port}\n")
return 0
end 'main'
What makes it legible for AI
Constraints live in the type system. Domain bounds are part of the type, not a comment — so an agent can't silently construct an invalid value.
typealias Port = int(0 to 65535)
let port = 8080 as Port // 70000 as Port is a compile error
No null to forget. Fallible reads must be resolved explicitly with try … otherwise.
There's no value to forget to check, so "missing null check" bugs can't occur.
let value = try inputVector.get(col) otherwise 0.0
Unambiguous structure. Every block names what it closes, so structure reads back clearly — for a human or a model.
while iteration < 10 'iterate'
applyAtA(previous, inputVector: current, dimension: size)
end 'iterate'
A serious language underneath
The AI story only holds up because the compiler does. Maxon is a real, fast, statically-typed, compiled language:
- Native backend — compiles straight to standalone executables, writing the object format itself. No LLVM, no VM, no assembler or linker, no external runtime.
- Reference-counted memory — deterministic cleanup the moment a value is no longer referenced. No garbage collector, no pauses.
- Strong inference + ranged types — static typing that stays terse, with ranged type aliases that encode real domain bounds into the types themselves.
- Structured diagnostics — stable error codes; the signal an agent uses to read a failure and correct itself.
- Self-hosting — Maxon compiles Maxon, and the compiler is a fixed point of itself: build it with itself twice and the two binaries are byte-identical.
- First-class tooling — a Language Server and VS Code extension ship with the language.
Project components
- Compiler (
maxon-bin) — the Maxon compiler, written in Maxon, which builds tomaxon-bin/.maxon/maxon. It emits standalone executables for every target it supports, with no external runtime — see docs/CLI_REFERENCE.md for the current list. - Language Server (LSP) —
maxon lsp-server, for IDE integration. - Model Context Protocol (MCP) —
maxon mcp-server, for AI coding agent tool integration. - Debug Adapter (DAP) —
maxon dap-server, the debugger an editor drives (every native target). - VS Code extension — syntax highlighting, language features and debugging.
Install
curl -fsSL https://maxon.dev/install.sh | sh # macOS and Linux
irm https://maxon.dev/install.ps1 | iex # Windows, in PowerShell
Both install into ~/.maxon (%USERPROFILE%\.maxon on Windows) and put maxon on your PATH, in the
terminal you ran them from as well as in new ones; maxon upgrade updates the install later. There is also brew install maxon-lang/tap/maxon, and an image,
ghcr.io/maxon-lang/maxon. Archives, a specific version and uninstalling are on the
installation page.
Building from source
Maxon is written in Maxon, so building it needs a Maxon compiler. There is no second implementation to fall back on — the published release is what seeds a build.
Prerequisites
- Git
- Node.js 20+ (only needed to build the VS Code extension)
Seed the build. scripts/fetch-seed.sh downloads the latest release (with an authenticated gh)
and places its binary at .bootstrap/maxon. Run it again after each release: an out-of-date seed can
fail the first build.
⚠ The binary alone, not the unpacked archive — the script copies only the executable. The compiler finds
stdlib/by walking up from its own executable, so a releasedstdlib/left beside it would be compiled instead of this tree's — silently, and the build would succeed.
Build and run
scripts/fetch-seed.sh # seed .bootstrap/ from the latest release ./.bootstrap/maxon build maxon-bin --output=maxon-bin/.maxon/maxon # first build, with the seed ./maxon-bin/.maxon/maxon run build # afterwards, it rebuilds itself maxon-bin/.maxon/maxon execute examples/basic.maxon # compile if needed, then run it maxon-bin/.maxon/maxon build examples/basic.maxon # or produce a binary to keep maxon-bin/.maxon/maxon spec-test # run the spec-test suite
⛔ Run a compiler that lives INSIDE this checkout — never one installed on your PATH. The
compiler finds stdlib/ by walking up from its own executable, so an installed maxon compiles this
repository's sources against the RELEASE's standard library. Measured: it succeeds and exits 0, having
built a compiler from a library that is not this tree's.
build with no path compiles build.maxon at the root and does what it says. The
compiler in the slot can rebuild itself: once the compile succeeds it renames its own running image to
maxon.previous and writes the new one in its place, so a failed build leaves the working compiler
where it was.
scripts/fixpoint.sh builds the compiler with itself twice and checks the two binaries are
byte-identical.
See docs/CLI_REFERENCE.md for every command and flag, or the installation guide for a step-by-step walkthrough.
Tests
Tests are organized as spec files in specs/: each language feature has a
single source of truth holding its documentation and its executable test cases together
(see docs/SPECS.md). Run them with:
maxon-bin/.maxon/maxon spec-test
When you change behavior, update or add the relevant spec and make sure the suite passes.
History
This repository starts at v0.1.0. Everything before it — the C# bootstrap compiler that first compiled Maxon, the first self-hosted compiler written in Maxon, and the ~5,800 commits that got from one to the other — is archived read-only at maxon-lang/maxon-bootstrap.
Nothing here depends on it. It is kept because a language that compiles itself has to have been compiled by something else first, and that is worth being able to look at.
Contributing
Maxon is written by AI and built in the open — so we prefer a fix to a bug report. An AI coding agent pointed at this repository can usually turn a failing program into a pull request, and the fix reaches everyone sooner than a report would. Clearer docs and real programs written in Maxon are welcome too, and so is a report of a bug you cannot fix. Start with CONTRIBUTING.md, join the discussions, or read the contributing guide on the site.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
来源:GitHub · github.com