Hello World
Let's write your first XXML program - the classic "Hello, World!"
The Code
Create a new file called hello.xxml with the following content:
#import Language::Core;
[ Entrypoint
{
Instantiate String^ As <message> = String::Constructor("Hello, World!");
Run Console::printLine(message);
Exit(0);
}
]Understanding the Code
Imports
#import Language::Core;This imports the Core module from the standard library, which provides essential types like String and functions like Console::printLine.
Entrypoint
[ Entrypoint
{
// Your code here
}
]The Entrypoint block defines where your program starts executing. Every XXML program needs exactly one entrypoint.
Variables with Ownership
Instantiate String^ As <message> = String::Constructor("Hello, World!");This creates an owned (^) String variable. The ownership modifier indicates that this variable owns the memory for the string.
Calling Functions
Run Console::printLine(message);The Run keyword executes a function. Here we're callingConsole::printLine to output our message to the console.
Compile and Run
xxml hello.xxml hello.exe
./hello.exeYou should see:
Hello, World!Next Steps
Congratulations! You've written your first XXML program. Continue to the Ownership guide to learn about XXML's unique memory management system.