GX
Beta, in active development

Fast. Typed.
Native.

A statically typed language for games, graphics and systems code. A program builds from its source files alone, with no build system. It compiles through C or LLVM on Windows, macOS and Linux, and to the web.

v0.8.8 beta for Windows, macOS and Linux
game.gx
struct Player {
name: str
health: i32
pos: vec3
}

fn main() {
var p = Player{"Alice", 100, vec3{0.0, 1.0, 0.0}}
p.health -= 10
print("Player {p.name} at ({p.pos.x}, {p.pos.y}, {p.pos.z})")
}
.gx → Lexer → Parser → Type Check → Backend
C Backend The default; runs wherever C does
LLVM (native) --backend=llvm: in-process, -O passes, DWARF
LLVM (text) --backend=llvm-clang: writes .ll for clang
JS Backend Runs the Playground in the browser
GPU Compute Planned: compute shaders in GX

What GX is for

Modern syntax, with the programmer still in charge of memory and performance.

⚡

C performance, modern syntax

There is no garbage collector and no runtime. A GX program compiles to a native executable through C or LLVM.

🛠

Three native backends

The default backend goes through C and the bundled compiler, which keeps builds fast. --backend=llvm generates code in-process with LLVM, with -O0 to -O3 and DWARF debug info. --backend=llvm-clang writes LLVM IR and needs only a clang binary. The language and the modules are the same on all three.

◆

Graphics types built in

vec2, vec3, vec4 and mat2, mat3, mat4 are part of the language, with the usual operators and swizzles such as v.xy and v.zyx.

🔗

C interop

Use a C library with @c_include and extern declarations. There is no bindings generator to run.

⚙

Compile-time code

#if for conditional compilation, #for to unroll loops, #fn for functions that run in the compiler, and #type for templates. All of it is resolved before code generation.

📦

Builds without a build system

Libraries and C sources are named in the source file with @link and @cfile. A program needs no CMake or Makefile.

⚖

Compile-time reflection

@fields(T), @field(T, i) and @members(E) walk the fields of a struct and the members of an enum while compiling.

Planned

GX is in beta. These are the next large pieces of work.

⚙ Planned

Interpreter backend

Run a program directly, without a C compiler or LLVM in the loop, for scripting and quick iteration. It sits next to the C and LLVM backends.

🎮 Planned

GPU compute

Run parts of a program on the GPU as compute shaders, written in GX rather than a separate shader language.

🤖 Planned

Tensors

A tensor type and GPU execution for machine learning, so training and inference can be written in GX itself.

✎ Available

Editor support

The compiler is also a language server (gx --lsp) for VS Code, Neovim, Vim, Emacs and Sublime. An IntelliJ plugin ships in every release too.

A short example

Math functions, string interpolation and compile-time reflection.

math_demo.gx
import math
struct Vec { x:f32 y:f32 z:f32 }


fn main() {
var angle: f32 = radians(45.0)
var result = sinf(angle)
print("sin(45) = {result}\n")

print("Vec has {@fields(Vec)} fields")
}

Try GX

Download the compiler, read the docs, or run code in the browser.

Beta builds by email

Leave your email and I’ll send you each new beta build of the compiler, with its release notes. Nothing else goes to that address.

Which platforms do you build for? (pick at least one)

More about the beta: /beta