Skip to content
Buntos edited this page Dec 5, 2026 · 2 revisions

H Programming Language Wiki

Welcome to the technical documentation for H (.hl), an ahead-of-time (AOT) compiled programming language built on LLVM. H pairs Ruby-style block syntax and dot-chaining with static type inference, compile-time nil safety, monomorphized generics, operator overloading, a hybrid memory model (Boehm GC plus unboxed structs, arenas, manual heap allocation, and @[nogc] verification), direct foreign language interoperability, and a self-hosted compiler written in H.

Documentation Map

Page Topics Covered
Getting Started Prerequisites (LLVM 19–23, Zig, GCC, Boehm GC), building and fixed-point verification, standalone installation (install.sh), hlc test, and h.toml manifests with [dependencies]
Language Guide Syntax, casing rules, built-in types, for .. in loops & ranges, operator overloading, default parameters, nil safety & Bool?, flow narrowing, UFCS chaining, &fn, closures, do blocks, payload enums, match, defer, and modules
Memory Model GC classes vs value structs, mut def, LLVM type layouts, String .rodata coercion, with_arena, Heap.alloc/free, @[nogc] verification, Ptr[T] auto-deref, and NPO optionals
Generics and Interfaces Monomorphized generic types and functions, type argument inference, interface declarations, < Interface conformance, [T: Bound] constraints, and Result[T, E] with ? propagation
Standard Library Module-by-module API reference for std/: math, str, path, fs, process, map, result, test, env, time, args, json, net, http, and thread
Foreign Interop extern "C" ABI (C, Zig, Rust, V, D -betterC), hl-bindgen-cpp C++ bridge, std/interop/druntime, std/interop/objc, and std/interop/dotnet (C# & F#)
Tooling and LSP hlc CLI flags, -g DWARF debugging, hlc test, hlfmt, zero-LLVM semantic hl-lsp, hl-bindgen-cpp, standalone install, editor setup (VS Code & Neovim), and build.zig targets
Compiler Architecture Frozen Zig bootstrap seed vs self-hosted compiler/*.hl, separated zero-LLVM compiler/typecheck.hl, trusted compiler/codegen.hl, LLVMRunPasses, pure-H @[nogc] runtime, fixed-point verification, and DWARF DIBuilder
Benchmarks Native -O3 performance measurements comparing H against C (gcc -O3) and Ruby across Sieve of Eratosthenes, N-Body simulation, and JSON throughput

Key Design Characteristics

  • Unambiguous Grammar: Uppercase identifiers ([A-Z]) are reserved strictly for types, while functions, methods, variables, constants, parameters, and fields start with [a-z_]. This allows [...] to disambiguate generic type arguments, element indexing, and array literals with single-token lookahead.
  • Compile-Time Nil Safety: All types are non-nullable by default (T? opts in to nil). Boolean operators and branch conditions reject Bool?, flow narrowing refines T? to T automatically, and pointer-backed optionals use zero-overhead Null-Pointer Optimization (NPO).
  • Predictable Performance: Garbage-collected class objects and Array[T] collections coexist with unboxed struct values, zero-cost operator overloading, inline StaticArray[T, N], scoped bump arenas (with_arena), manual Heap allocation, and statically verified @[nogc] functions.
  • Self-Hosted Compiler & Shared Zero-LLVM Typechecker: The compiler (compiler/*.hl), runtime library (runtime/hl_runtime.hl), standard library (std/*.hl), and developer tools (tools/*.hl) are written in H. compiler/typecheck.hl has zero LLVM dependency and is shared verbatim between hlc and hl-lsp.

Additional Repository References

  • Language specification: SPEC.md
  • Example programs: examples/
  • Benchmarks: benchmarks/
  • Editor integrations: editors/
  • Native pure-H test suite: tests/

Clone this wiki locally