mx transpiles Modula-2 to C, then calls the system C compiler to produce native executables. It implements PIM4 with optional Modula-2+ extensions (exceptions, reference types, objects, concurrency) via --m2plus.
- Grammar fits on a page (~40 reserved words)
- Separate interface (
.def) and implementation (.mod) per module - No implicit conversions, no header file resolution order issues
- Strict static type checking
Transpiling to C rather than emitting native code directly gives:
- Portability — any platform with a C compiler is a target. Cross-compile by setting
--cc. - Source-level debugging —
#linedirectives map back to.modsource in LLDB/GDB. - C FFI — bind to any C library with
DEFINITION MODULE FOR "C". - Inspectable output — generated C is readable.
The toolchain also includes a package manager (mxpkg), an LSP server, a VS Code extension, and 33 libraries (see libs/).
Requires Rust (cargo) and a C compiler (cc/clang/gcc).
git clone https://github.com/fitzee/mx.git && cd mx
make installAdd to your shell profile:
export PATH="$HOME/.mx/bin:$PATH"OpenSSL 3 is required (brew install openssl@3 on macOS, sudo apt install libssl-dev on Linux). Optional: SQLite3, zlib.
cat > hello.mod << 'EOF'
MODULE Hello;
FROM InOut IMPORT WriteString, WriteLn;
BEGIN
WriteString("Hello, world!");
WriteLn;
END Hello.
EOF
mx hello.mod -o hello && ./hellomx build # compile
mx run # compile and run
mx test # run testscode --install-extension tools/vscode-m2plus/m2plus-*.vsixdocs/ai/ contains structured references for use with coding agents:
- Language rules and compiler constraints
- Syntax patterns and idiomatic templates
- Module resolution and import mechanics
- API signatures for all 33 libraries
- Build system and project manifest format
See docs/ai/CLAUDE.md for reading order.
Language reference, library APIs, LSP configuration, and contributor guides are in docs/. Version history in RELEASE_NOTES.md.
src/ Compiler (Rust)
libs/ 33 libraries (Modula-2)
tools/mxpkg/ Package manager (Modula-2+)
tools/vscode-m2plus/ VS Code extension
examples/ Categorized examples and demos
tests/ Unit, adversarial, conformance
docs/ Documentation
cargo test # unit tests
bash tests/run_all.sh # integration tests
bash tests/conformance.sh # conformance tests
python3 tests/adversarial/run_adversarial.py --mode ci # adversarial testsMIT License
Copyright (c) 2026 Matt Fitzgerald
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.