Skip to content

Gui Architecture

Cross-platform GUI framework for the Axon programming language.

Version: Draft β€” Pre-implementation
Status: Planning (M9-M12)
Target: macOS (primary), Linux, Windows


Axon apps are fully compiled native binaries that run on any OS with the Axon runtime installed. The GUI framework ships as part of the Axon distribution β€” no external dependencies required at deploy time.

Developer writes Axon code β†’ axonc compiles β†’ native binary
User has Axon runtime installed β†’ runs the app
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Axon Application β”‚
β”‚ (pure Axon code β€” business logic + UI) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ axon.ui Module (Axon) β”‚
β”‚ Widgets, layout helpers, theme API β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UI Framework (C: libaxon_ui) β”‚
β”‚ Layout engine, event dispatch, widget state β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Rendering Engine (C: libaxon_render) β”‚
β”‚ Software rasterizer, text, images β”‚
β”‚ GPU backends: Metal (macOS), Vulkan (Linux/Win)β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ macOS β”‚ Linux β”‚ Windows β”‚
β”‚ AppKit β”‚ X11/Wayland β”‚ Win32 β”‚
β”‚ (ObjC β”‚ (Xlib/ β”‚ (CreateWindow, β”‚
β”‚ runtime)β”‚ libwayland) β”‚ WndProc) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Platform Abstraction Layer (C: libaxon_pal)

The platform-specific code is written in C (and Objective-C for macOS). Axon programs call into it via extern declarations. This means:

  • Zero Objective-C/Win32/X11 knowledge needed for Axon developers
  • Battle-tested C interop β€” no new FFI mechanisms required
  • Ships with Axon β€” libaxon_pal and libaxon_render are part of the distribution

The initial renderer is a CPU-based 2D rasterizer β€” no GPU required. This ensures:

  • Works everywhere (SSH, CI, headless, old hardware)
  • Simpler implementation and debugging
  • GPU backends (Metal, Vulkan) added later for performance

The first UI framework is immediate-mode (like Dear ImGui/Nuklear):

;; Every frame, describe the UI
(if (ui.button ctx "Click Me")
(set count (add count (i64 1))))
(ui.label ctx (fmt "Count: {}" count))

Why immediate-mode first:

  • Fewer language features needed (no closures for callbacks)
  • State lives in user code, not framework
  • Simpler to implement and debug
  • Good enough for tools, dashboards, and many apps

Future: Declarative mode (like SwiftUI) once Axon has closures and generics.

Layout uses a flexbox-like algorithm β€” the same model used by CSS, React Native, and Flutter. Well-understood, well-tested, handles 95% of UI layouts.

Uses the Objective-C runtime C API β€” no Objective-C compiler required:

// Create an NSWindow from pure C
id window = ((id(*)(id,SEL,CGRect,int,int,int))objc_msgSend)(
((id(*)(id,SEL))objc_msgSend)((id)objc_getClass("NSWindow"),
sel_registerName("alloc")),
sel_registerName("initWithContentRect:styleMask:backing:defer:"),
frame, 15, 2, 0);

Key runtime functions: objc_msgSend, objc_getClass, sel_registerName, class_addMethod.

Link flags: -framework Cocoa

Two backends:

  • X11 (via Xlib) β€” widest compatibility, simpler API
  • Wayland (via libwayland) β€” modern compositors, more complex

Framebuffer via MIT-SHM (X11) or wl_shm (Wayland) for zero-copy pixel blitting.

Link flags: -lX11 -lXext

Uses Win32 API: CreateWindowEx, GetMessage/DispatchMessage loop, GDI for framebuffer.

Link flags: -lgdi32 -luser32 -lkernel32

The GUI framework requires these language features (planned for M2-M5):

FeatureMilestoneWhy Needed
Function pointersM2Event callbacks
EnumsM2Event types, widget states
Pattern matchingM2Event dispatch
GenericsM2Type-safe containers
Result typesM3Fallible operations
Multi-file modulesM4Code organization
Heap allocationM5Widget trees, buffers
String typeM5Text everywhere
Dynamic arraysM5Widget children
Hash mapsM5Widget lookup, styles
MilestoneFocusKey Deliverable
M9Platform Layerlibaxon_pal β€” windows, events, framebuffer
M10Renderinglibaxon_render β€” shapes, text, images
M11UI FrameworkLayout, widgets, themes, axon.ui API
M12PolishFull widgets, app bundling, tooling
  • Declarative UI β€” SwiftUI-like syntax with closures and reactive state
  • Custom UI DSL β€” .axui files compiled alongside .axs code
  • WebAssembly target β€” Run Axon GUI apps in browsers
  • Mobile β€” iOS (UIKit) and Android (NDK) backends
  • 3D rendering β€” Scene graph, shaders, game engine integration