A language for code that must be believed.
M9 is a Wirth-family language that is readable like a bank statement and checked like Rust. Every rule exists because of a real bug, and the compiler refuses that bug instead of letting the program run on and quietly produce a wrong number.
MODULE X2Assign ;
IMPORT Io ;
VAR
i : I64 ;
x : F64 ;
BEGIN
x := 2.5 ;
i := x ;
Io.WriteI64 (i)
END X2Assign.
The compiler is tested on every build to make sure this program never compiles. Run it in your browser, no installation needed.
For results you have to reproduce
Every number type names its width, and nothing converts on its own. A wrong conversion stops the program instead of slipping a bad value into your mean. The tutorial goes from first steps to a real ICOS CO2 series read through zarr, a NetCDF file, regressions, and threads.
Start the tutorialFor code an AI agent writes
Types, failure modes, effects, and thread safety are stated in definition modules, and the compiler checks them all. Checks can't be turned off. M9 was itself written by an agent under review, and its claims are checked the same way.
Read the reportMeasured, not claimed
- Runtime checks cost about 3%, and can't be switched offBenchmarks
- Mandelbrot runs as fast as C, from a 26 KB executableMethod
- The compiler compiles itself to byte-identical outputBootstrap
- The zarr reader matches numpy to the last digitChapter 8
- Each language feature cites the bug it makes uncompilableThe report
Install
Linux: packages for Ubuntu, Debian, Fedora, Rocky, and Arch, or build from source with only gcc.
./build.sh
macOS on Apple silicon, experimental.
brew tap atverm/m9
brew install m9
Windows 10 and 11, experimental: a zip with its own gcc and one installer. All releases
Resources
Your programs are yours
The compiler and tools are free software under the GNU GPL, version 3. The runtime and standard library carry a runtime exception, so programs you build with M9 can be released under any license you choose, open or proprietary. Changes to the compiler itself remain under the GPL.
Read the runtime exception
This file grants an additional permission under section 7 of the GNU General Public License, version 3. It applies to the Runtime Library of Modula-9, which consists of the C runtime (runtime/m9rt.c and runtime/m9rt.h, and the C files beside them in runtime/: the shims programs link and m9session.c), the standard library modules listed in RUNTIME-LIBRARY-FILES, and any code m9c copies from these into the C it generates.
It does not apply to the compiler m9c and its modules, the bootstrap C in runtime/gen/, or the tools (m9lsp, m9fmt, m9elide, the editor extension, and the Jupyter kernel). These remain under the GPL alone.
The permission is the GNU Classpath exception, reproduced verbatim, where “this library” means the Runtime Library:
Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
Compiler output. The C code m9c generates from your program is not a work based on m9c merely because m9c produced it. Where that code contains material copied from the Runtime Library, the permission above covers that material.