Hello, World!
Writing a "Hello, World!" program is a long-standing tradition when learning a new programming language. It demonstrates the minimal structure of a valid program and verifies that your development environment is working correctly.
The Program
fn main() {
puts("Hello, World!");
}
Program Structure
Every executable Juno program begins with a function named main.
fn main() {
}
When the program starts, the runtime automatically calls main(). Execution ends when this function returns.
Printing Text
The printf() built-in function writes a string to the standard output followed by a newline.
printf("Hello, World!");
The output will be:
Hello, World!
Statements
Each statement ends with a semicolon (;).
printf("Hello");
printf("World");
Omitting the semicolon results in a compilation error.
Strings
Text enclosed in double quotes (") is a string literal.
printf("Juno");
printf("Programming Language");
Strings can contain letters, numbers, punctuation, and escape sequences.
What's Next?
Now that you've written your first program, continue with the next chapter to learn how to create and organize Juno projects.