R2ND Docs
Everything you need to build with the R2ND ecosystem — from installation to shipping a full UI app.
Reference Documentation
Introduction
R2ND stands for "Road to No Dependencies" — a self-hosted ecosystem built entirely from scratch. Custom language, UI framework, renderer, package manager — all with zero external dependencies.
At the core is M++, a compiled language that emits LLVM IR and produces native binaries via clang. The toolchain, standard library, and every layer of the stack are written from the ground up.
Pipeline: .mpp → LLVM IR → clang → native binary
Installation
The R2ND installer handles everything automatically. Download it from files.r2nd.org and run it.
# Download and run the installer # From: https://files.r2nd.org/installers/r2nd_setup.exe # The installer will: # 1. Download mpp.exe (M++ compiler) # 2. Download r2nd.exe (CLI tool) # 3. Bundle LLVM/clang if not found # 4. Install C++ build tools if needed # 5. Add everything to PATH # After install, restart your terminal: mpp --version
LLVM & Build Tools: The installer automatically detects and bundles LLVM/clang. If Visual Studio Build Tools are missing, it installs them too.
Install scope: Supports both per-user and system-wide installation.
Quick Start
Create a new project and run it in two commands:
# Create a new project mpp init # Creates: mpp.toml, src/main.mpp, .mpp_packages/ # Build and run mpp build --run
The generated src/main.mpp:
fn main() {
print("Hello from my-project!");
}Project Structure & Build System
mpp.toml
name = "my-app" version = "1.0.0" main = "src/main.mpp" opt = "0" [dependencies] r2nd-ui = "0.1.0"
Commands
mpp init— Create new projectmpp build— Compile projectmpp build --run— Compile and runmpp install <package>— Install a packagempp <file.mpp> --llvm— Compile single fileProject layout
my-app/ ├── mpp.toml # Project config ├── src/ │ └── main.mpp # Entry point ├── examples/ # Example files └── .mpp_packages/ # Installed packages
Package System
# Install a package mpp install r2nd-ui # This downloads from files.r2nd.org/packages/ # Adds to mpp.toml [dependencies] # Extracts to .mpp_packages/r2nd-ui/ # Use in code: import "r2nd-ui"
M++ Language
Looking for the full reference? The complete M++ language documentation with search, 21 sections, and comprehensive examples is at M++ Language Reference →
Quick overview of the language:
Variables & Types
let name = "R2ND"; let mut count: int = 0; let pi: float = 3.14159; let active: bool = true;
Functions
fn add(a: int, b: int) -> int {
return a + b;
}
fn greet(name: string) {
print("Hello, " + name + "!");
}Arrays & Loops
let items = ["one", "two", "three"];
let mut i = 0;
while i < len(items) {
print(items[i]);
i = i + 1;
}Structs
struct Point {
x: float,
y: float
}
let p = Point { x: 1.0, y: 2.5 };
print(p.x);Imports
import "utils.mpp" import "r2nd-ui" // package import
Built-in Functions
printinputlenpushpopto_stringto_intparse_inttrimsplitfile_readfile_writefile_existsdir_listexecallocfreegetenvR2ND UI Framework
A complete, zero-dependency UI framework. Declare layout in R2ML (XML), wire logic in M++.
Setup
mpp init mpp install r2nd-ui
Layout — examples/app.r2ml
<window width="800" height="600" bg="181825" layout="flex-col">
<div height="48" bg="1e1e3a" layout="flex-row" padding="12">
<label height="28" fg="a0b0ff" font-scale="2">My App</label>
<div grow="1"></div>
<button width="80" height="28" bg="3050c0" fg="ffffff" radius="6">Click Me</button>
</div>
<div grow="1" bg="1a1a2e" layout="flex-col" padding="20">
<label height="24" fg="d0d8ff">Welcome to R2ND UI!</label>
</div>
</window>Logic — src/main.mpp
import "r2nd-ui"
let mut root: int = -1;
fn load_ui(w: int, h: int) {
root = r2ml_load("examples/app.r2ml");
ui_set(root, EF_W, w);
ui_set(root, EF_H, h);
ui_layout(root);
}
fn on_resize(w: int, h: int) {
ui_set(root, EF_W, w);
ui_set(root, EF_H, h);
ui_layout(root);
}
fn on_click() {
ui_set_text(evt_target, "Clicked!");
}
fn main() {
let hwnd = win32_create_window("My App", 800, 600);
win32_show_window(hwnd);
gfx_init(800, 600);
timer_init();
ui_init();
ui_events_init();
load_ui(800, 600);
// Bind click to all buttons
let mut i = 0;
while i < ui_elem_count {
if ui_get(i, EF_TAG) == ETAG_BUTTON {
ui_on(i, EVT_CLICK, on_click as ptr);
}
i = i + 1;
}
let msg = alloc(48);
while win32_running {
while (PeekMessageA(msg, null, 0u32, 0u32, 1u32) as int) != 0 {
TranslateMessage(msg);
DispatchMessageA(msg);
}
if !win32_running { break; }
if win32_width != fb_width || win32_height != fb_height {
gfx_resize(win32_width, win32_height);
on_resize(win32_width, win32_height);
}
ui_process_events(root);
gfx_clear(rgb(24, 24, 37));
ui_render(root);
gfx_present(hwnd);
win32_clear_input();
Sleep(1u32);
}
free(msg);
}R2ML Reference
Elements
windowdivlabelbuttoninputAttributes
widthheightbgfgborderlayoutgappaddinggrowradiusoverflowfont-scaleUI API Functions
ui_initui_events_initui_layoutui_renderui_process_eventsui_onui_setui_getui_set_textui_get_textr2ml_loadgfx_initgfx_resizegfx_cleargfx_presentCLI Reference
| Command | Description |
|---|---|
mpp init | Create new project with mpp.toml |
mpp build | Build project from mpp.toml |
mpp build --run | Build and run |
mpp install <pkg> | Install package from files.r2nd.org |
mpp <file> --llvm | Compile single file |
mpp <file> --llvm -q | Compile quietly |
mpp <file> --llvm --run | Compile and run single file |
r2nd mpp build | Same as mpp build (via r2nd CLI) |
r2nd --version | Show version |