Hello World
Create and run your first Morph project in under a minute.
Step 1: Create a New Project
morph new myproject
This generates the following structure (names match the morph new scaffold in the toolchain):
myproject/
├── morph.toml
├── .morphsettings
├── .productsettings
├── .gitignore
├── assets/
├── src/
│ └── Main.mx
├── docs/
│ └── scripts/
│ └── Main.md
├── tests/
│ ├── auto/
│ └── unit/
├── agents/
│ ├── language/
│ │ └── Details/
│ ├── project/
│ └── learnmorph/ # copied from toolchain when available
├── modules/
└── build/
Step 2: Explore Main.mx
Open src/Main.mx. A freshly generated application project looks like this (the exact greeting string uses the branded display name, typically "Morph"):
// myproject - Morph Project
Init is method()
{
Print("Hello Morph!");
};
What's Happening?
Initis the program's entry point — likemain()in C/C++.is method()declares an instance method with no parameters and no return type.Print(...)is a built-in that outputs to the console.- The closing
};matches what the project generator emits; style may vary, but this form is always valid.
Step 3: Run It
cd myproject
morph run
You should see the Print output from Init in the console.
Step 4: Modify the Program
Edit src/Main.mx:
Init is method()
{
name is "World" as string;
count is 3 as int;
for(i is 0; i < count; i++)
{
Print("Hello, " + name + "!");
}
};
Run again with morph run.
With is vs Without is
Both of these are valid for method headers:
Init is method()
{
Print("Hello!");
};
Init method()
{
Print("Hello!");
};
Convention: Use is for variable bindings. For method declarations, either form is acceptable; the project generator uses Init is method().
Next Steps
- Morph framework overview — Why
morphs/drives the real compiler pipeline - Project Structure — Understand every file and directory
- Variables — Learn how variables work