The Onyx Programming Language

A data-oriented, expressive, and modern programming language

$ # Install Onyx in one command
$ sh <(curl -sSfL) Copy
$ # Read the docs
$ # Try Onyx in your browser

Language Features

For full language documentation and reference see the Onyx Book.


Onyx uses a modernized C-like syntax, similar to Jai or Odin. Onyx is a procedural language, but does allow for functional-inspired syntax using the pipe operator.

use core { printf, iter }

main :: () {
    for i in 1 .. 10 {
        fact := factorial(i);
        printf("{}! = {}\n", i, fact);

factorial :: (n: i32) -> i32 {
    return iter.as_iter(1 .. n)
        |> iter.fold(1, (x, y) => x * y);

Type Safety

Onyx is strictly type-checked. However, the type-inference systems in Onyx usually allow you to omit types.

use core { printf }

main :: () {
    // Inferred variable type
    x := 10;

    // Function with entirely inferred types.
    change_value :: x => x + 10;

    // Onyx figures out the types of `change_value` when you call it.
    printf("The value is {}.\n", change_value(x));

Fast Compilation

Onyx's compiler is written entirely in C and features incredibly fast compilation. The web-server for this website was compiled in 47 milliseconds.

$ onyx build -V -r wasi -DWASIX -o site.wasm build.onyx
File search path:

Type table size: 151092 bytes.
Foreign blocks size: 8 bytes.
Tagged procedure size: 840 bytes.
Tagged global size: 8 bytes.

    Time taken: 47.000000 ms
    Processed 22144 lines (471148.937500 lines/second).
    Processed 115240 tokens (2451915.000000 tokens/second).

Outputting to WASM file:   site.wasm


Onyx compiles solely to WebAssembly. You can use a builtin WebAssembly runtime using onyx run, or compile to WASM and run using a WebAssembly runner, like Wasmer or Wasmtime.

# Compile and run directly.
$ onyx run hello.onyx
Hello, World!

# This time target 'WASI'.
$ onyx build -r wasi -o hello.wasm hello.onyx

# Run using Wasmer.
$ wasmer run hello.wasm
Hello, World!


Onyx features built-in support for linking to native C-libraries.

use core {*}

// Using #dyncall dynamically loads the library at runtime.
#foreign #dyncall "" {
    write :: (fd: i32, data: [&] u8, count: i32) -> i32 ---

main :: () {
    msg: [] u8 = "Hello, libc!";

    write(1,, msg.length);

More examples

See more complete examples on the Examples page.

Onyx Community

The Onyx programming language is on Discord! It is the place to chat about language features, discuss problems you are having, and showcase your projects.

Onyx is an open source project so contributions from the community are welcome and encouraged! The onyx-lang/onyx GitHub repository is the official source of Onyx.

Join Discord Go to GitHub

Recent News

Beta Release 0.1.9

19th February 2024

This release brings major syntax changes, optional semicolons, OVM-WASM support for MacOS, and a host of bugfixes in the compiler and the standard library.

Beta Release 0.1.8

28th November 2023

This is an exciting release for Onyx! It is the first release to ship with MacOS support and an automated installer. It also brings many improvements to package management and the general ergonomics of the language.

© 2020-2024 Brendan Hansen