Overview

GX is a procedural, statically-typed programming language inspired by C.
It compiles through a pluggable backend architecture, currently targeting C.

Design Goals

  • Deterministic behavior
  • Zero hidden allocations
  • C-compatible layout and ABI
  • UTF-8 native strings
  • Clean and predictable syntax
  • Direct interoperability with C libraries
  • Pluggable backends for different targets

Non-Goals

  • No borrow checker
  • No hidden runtime
  • No garbage collector
  • No inheritance-based OOP

GX assumes the programmer is responsible and values clarity over cleverness.

Compilation Model

GX Source → Frontend (Lex/Parse/Resolve/TypeCheck) → Backend → Output

The default C backend pipeline:

GX → C → Native executable

The compiler’s frontend and backend are cleanly separated. The frontend produces a resolved, typed AST. The backend consumes it through a pluggable Backend interface.

Current backend: C Transpiler (generates portable, readable C code).

Planned backends: LLVM, interpreter, GPU compute shaders.

Standard Modules

GX ships with reusable modules in the modules/ directory:

  • math — Scalar math (trig, sqrt, clamp, lerp), vector utilities (length, normalize, distance), and matrix transforms (perspective, look_at, multiply). See 07_Math_Module.
  • sokol — Bindings for Sokol graphics/app/input libraries.

Import with import math.scalar, import math.vec, import math.mat.

Architecture

src/
  frontend/       Lexer, Parser, Resolver, Type Checker, Module Loader
  backend/c/      C transpiler + C compiler invocation
  driver/         CLI argument parsing
include/gx/
  backend/        Abstract Backend interface (backend.h)
  version.h       Single-source version definition
modules/
  math/gx/        Math module (scalar, vec, mat)
  sokol/          Sokol bindings (app, gfx, glue, gp)

Versioning

GX follows Semantic Versioning. The version is defined once in include/gx/version.h and propagated to all compiler output and generated code automatically.