typestar

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

  1. def main(): is the entry point the compiler looks for.
  2. var declares a binding, and String("Mojo") builds the value.
  3. print takes several arguments and separates them with spaces.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 6 in Variables & functions, step 1 of 26 in Language basics.

Next →