The Onyx Programming Language

An efficient, procedural, and pragmatic programming language

Efficient


The Onyx compiler is fast. Turnaround time is non-existent using Onyx's custom WebAssembly code generator.

Procedural


Onyx uses a simple programming and memory model. It is familiar to anyone with any programming experience.

Pragmatic


Onyx exists to solve real problems. It provides a wide-range of orthogonal language features to fit any task.

Read about design goals of Onyx.

Install Onyx

Run the following command on your Linux or MacOS system to install the latest version of Onyx.

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

Read the Installation Guide for more details.

Language Features

For full language documentation and reference see the Onyx Book.

Modern Syntax


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 Iterator.from(1 .. n)
        |> Iterator.fold(1, (x, y) => x * y)
}

Type Safety


Onyx is strictly type-checked. The type-inference in Onyx allows for many types to be omitted with out sacrificing safety.

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("Value: {}.\n", change_value(x))
}

Fast Compilation


Onyx's compiler is written entirely in C and features a incredibly fast compilation. The server for this site was compiled in just 67 milliseconds.

$ onyx build -V build.onyx

Statistics:
    Time taken: 67.000000 ms
    Processed 32737 lines (488611.937500 lines/second).
    Processed 192781 tokens (2877328.250000 tokens/second).

WebAssembly


Onyx compiles solely to WebAssembly. You can use a builtin WebAssembly runtime using onyx run, compile to WASM and run using a WebAssembly runner, or even compile to a native executable on Linux or MacOS.

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

# This time target 'WASI' and run using Wasmer.
$ onyx build -r wasi -o hello.wasm hello.onyx
$ wasmer run hello.wasm
Hello, World!

# Compile to a native executable.
$ onyx build-exe -o hello hello.onyx
$ ./hello
Hello, World!

C-FFI


Onyx features built-in support for linking to native C-libraries on Linux and MacOS.

use core {*}

// Using #dyncall dynamically loads
// the library at runtime using dlopen().
#foreign #dyncall "libc.so" {
    write :: (fd: i32, msg: [] u8) -> i32 ---
}

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

    write(1, msg)
}

Examples

Learn more from 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.

Recent News

Beta Release 2611

23rd November 2026

The past two years of Onyx development has been sporadic and infrequent, but fruitful. This release brings new compilation targets, new integrations, and more stability.

Beta Release 0.1.13

8th November 2024

Its been nearly 6 months since a release of Onyx — which is way too long! I've been putting off releasing this version until I felt there were enough changes to justify a new release. Now there are so many little changes made over these past months, it is due time to push them out to everyone!