Getting Started

Back to the docs

This short guide will walk you through getting Onyx installed on your system, creating your first project, and running your first program. There are more in-depths guides after this one.

Install Onyx

On any Linux, MacOS, or WSL system, run the following command to install Onyx onto your system.

sh <(curl https://get.onyxlang.io -sSfL)

For more details, or how to install on Windows, see the installation docs.

Create an Onyx project

This is an optional step, but does set you up to use packages in your project. Learn more about the package manager here.

Create a new directory and setup a new project. Optionally project values when prompted.

$ mkdir my-onyx-project
$ cd my-onyx-project
$ onyx package init
Creating new project manifest in ./onyx-pkg.kdl.

Package name: my-onyx-project
Package description: My first Onyx project
Package url: 
Package author: Brendan Hansen
Package version (0.0.1):

Write your first Onyx program

Open your favorite text editor, optionally install editor support, and create a new file called main.onyx in this project folder. Write the following code in that file.

use core {printf}

main :: () {
    printf("Hello, Onyx!\n");
}

This code brings in the printf symbol from the core libraries so we can print to the console. Then in the main function, we print "Hello, Onyx!".

Run your program!

To run our newly created program, we use the following command from within the project folder.

$ onyx run main.onyx
Hello, Onyx!

Congratulations! You just wrote your first Onyx program.

Now you can read the docs and experiment with Onyx in this project.

© 2020-2024 Brendan Hansen