Hello from Mojo in Mojo
The smallest complete Mojo program - an entry point and a print.
def main():
var language = String("Mojo")
var year = 2023
print("Hello from", language)
print(language, "was announced in", year)
How it works
def main():is the entry point the compiler looks for.vardeclares a binding, andString("Mojo")builds the value.printtakes several arguments and separates them with spaces.
Keywords and builtins used here
Stringdefmainprintvar
The run, in numbers
- Lines
- 5
- Characters to type
- 129
- Tokens
- 34
- Three-star pace
- 100 tpm
At the three-star pace of 100 tokens a minute, this run takes about 20 seconds.
Step 1 of 6 in Variables & functions, step 1 of 26 in Language basics.