How to Set Up Mojo and Run Your First Hello World

Mojo

Getting started with a new language can be tricky, but Mojo makes it surprisingly simple. In this guide, you’ll learn how to set up your Mojo environment and run your very first “Hello World” program.

Introduction

Mojo is an emerging programming language that combines the simplicity of Python with the performance of C++. In this tutorial, you’ll learn how to install Mojo and run your very first Hello World program.

Step 1: Gain Access to Mojo

Currently, Mojo is available through a waitlist system on Modular’s official site. You can request access here:

Mojo 🔥: Powerful CPU+GPU Programming
Mojo is a programming language that enables fast & portable CPU+GPU programs to execute via the MAX Platform

Step 2: Install Mojo SDK

Once you have access to Mojo, follow the installation instructions provided by Modular. In most cases, you’ll run commands like the following in your terminal:

# ✅ Clone the Mojo SDK repo (example)
git clone https://github.com/modularml/mojo

# ✅ Change directory
cd mojo

# ✅ Install dependencies and activate the environment
pip install -r requirements.txt
source ./activate.sh

💡 Note: The actual steps may vary depending on updates from Modular.

Step 3: Create and Run Your First Program

Now let’s write a simple Hello World program in Mojo. Create a file called hello.mojo and paste the following code:

fn main():
    print("Hello, world!")

Then, run the program using the Mojo command-line tool:

mojo hello.mojo

Conclusion

Mojo provides an exciting way to develop high-performance AI applications using a Python-like syntax. With a simple setup and familiar syntax, it’s worth keeping an eye on as it continues to evolve.

The following summarizes Mojo’s variables, data types, and operators.

Comment

Copied title and URL