What Is Morph?
Morph is a high-performance, compiled programming language designed for artificial intelligence, scientific computing, and GPU-accelerated workloads.
Design Goals
Morph is built around four core principles:
| Principle | Description |
|---|---|
| C++ Performance | Compiles to native machine code — no interpreter overhead |
| Readability | Natural-language keywords instead of cryptic symbols |
| Simple Memory Model | Alias-by-default with explicit copy and move controls |
| GPU & Tensor Native | First-class tensor types and gpu { } execution blocks |
The Morph Framework (this is the main event)
The language syntax you learn in these tutorials (control flow, types, tensors, GPU blocks, modules, tests, …) is almost entirely owned by Morph packages under morphs/, not baked in as permanent src/parser specials. Each package exports semantic extensions, NIR lowers/optimizers, backend routes (host.llvm, Vulkan, SPIR‑V, NN graph, REPL, …), runtime families, and even nested CLI tooling—wired through the package root morph.toml, nested feature.toml and block.toml (grammar [forms.*]), and the stable ABI in MorphABI.h.
So Morph is two things at once: a compiler host and a composable plugin graph. If you only read syntax chapters, you miss why features are portable and where to add new ones.
Start here: Morph framework overview · Plugin-governed pipeline.
How It Works
Morph separates how sources are compiled from how they are shipped or sandboxed.
1. LLVM native path (typical morph build / morph run)
For normal projects, morph build and morph run drive the LLVM-oriented pipeline end-to-end: frontend → NIR → LLVM → native executable. See Build pipeline.
Source (.mx) → Lexer → Parser → Semantic analysis → NIR → LLVM → native binary
2. Web target (morph build --target=web / morph run --target=web)
Web builds emit artifacts under build/web and use the browser/WASM stack configured in [web] inside morph.toml.
3. VCON containers (morph vcon …)
Portable bytecode + VM flows are handled under morph vcon, not by plain morph run. Use VCON when you need the sandboxed container model, nucleus embedding, or morph vcon watch-style hot reload.
Source (.mx) → … → NIR → bytecode / container tooling → .vcon → VM or nucleus host
Key Features
iskeyword for variable binding (optional for methods and classes)anotherfor deep copies,movefor ownership transferaddress of/value of— readable pointer syntax- One class per file — enforced by the compiler
gpu { }blocks with automatic CPU fallback- First-class tensors with
@matrix multiplication - Generics with type constraints
async/awaitconcurrencytry/catch/finallyerror handling- VCON for portable, sandbox-oriented containers (
morph vcon …) - Hot reload via
morph vcon watch(VCON workflow), not via ordinarymorph run
A Quick Look
module System;
Init is method() {
x is 42;
y is another x;
name is "Morph" as string;
Print(name);
Print(x + y);
}
This program (e.g. in Main.mx):
- Declares a dependency on the
Systemmodule (built-in I/O helpers such asPrint; see Standard library). - Declares
xas an alias-bound integer. - Creates
yas an independent copy ofx. - Prints
"Morph"and84.
Next Steps
- Installation — Set up the Morph toolchain
- Project Structure — Understand the directory layout