Self-hosted · Native LLVM · Linux x86_64

The H Programming Language

Ruby-style readability. Native LLVM speed. GC when you want it, manual control when you don't.

H (.hl) compiles straight to native machine code, checks nil and types before your program runs, lets you opt into zero-GC arenas per function, and connects directly to C, C++, Objective-C, D, C#, and F#.

Quick install — Linux x86_64
$ git clone https://github.com/buntatoes/h-lang.git && cd h-lang
$ zig build self-host && zig build tools && ./scripts/install.sh
$ hlc run examples/hello.hl
Self-Hosted
Compiler, runtime, stdlib, formatter, and LSP are written in H.
Zero-LLVM LSP
hl-lsp shares the pure-H typechecker with zero LLVM dependency.
6 Foreign Languages
Connect cleanly to C, C++, Objective-C, D, C#, and F#.
Apache 2.0
Open source and reproducible from source on Linux x86_64.
Code Showcase

Write high-level code. Drop low-level when it counts.

Explore real H programs — from everyday structs and safe error handling to zero-GC arenas, HTTP JSON routes, and multi-language interop.

vec2.hl
struct Vec2
  x: F64
  y: F64

  @[nogc]
  def +(other: Vec2) -> Vec2
    Vec2.new(@x + other.x, @y + other.y)
  end

  @[nogc]
  def length_sq() -> F64
    @x * @x + @y * @y
  end
end

def main() -> I32
  pos = Vec2.new(3.0, 4.0) + Vec2.new(1.0, -1.0)
  total = 0
  for i in 1..=5
    total += i
  end
  puts("pos=(#{pos.x}, #{pos.y}) len2=#{pos.length_sq} sum=#{total}")
  0
end

Stack-allocated struct values, overloaded operators, inclusive 1..=5 ranges, and Ruby-style string interpolation.

pos=(4, 3) len2=25 sum=15
Why H

Designed to feel clean without hiding the machine.

H aims for a practical middle ground: readable enough for everyday apps and tools, predictable enough for tight loops and native libraries.

Easy to read

Clean def ... end blocks, for ... in loops, string interpolation ("hello #{name}"), and dot-chaining without noisy boilerplate.

Safe about nil

Values cannot be nil unless their type ends in ? (like User?). The compiler checks your branches and gives you ??, &., and Result[T, E] with ?.

Fast native binaries

H compiles ahead of time to native machine code using LLVM optimizations (-O1 through -O3) — no virtual machine or interpreter at runtime.

Choose your memory style

Use garbage-collected classes when convenience matters, or switch to stack structs, scoped with_arena buffers, manual Heap allocation, and verified @[nogc] functions when you want zero pauses.

Built to talk to other languages

Call C libraries directly with extern "C", generate C++ wrappers with hl-bindgen-cpp, or connect to D, Objective-C, C#, and F# through built-in runtime bridges.

Self-hosted toolchain

The H compiler, runtime, standard library, formatter, and language server are written in H itself and pass bit-for-bit fixed-point verification. A small Zig seed exists only to bootstrap on a new machine.

Honest Benchmarks

Real measurements, with the trade-offs explained.

Measured on Linux x86_64 via benchmarks/run.sh at -O3 against C (gcc -O3) and Ruby, checking identical output checksums on every run. Lower is faster.

Command: ./benchmarks/run.sh · hlc -O3 vs gcc -O3 & Ruby · CLOCK_MONOTONIC

Prime Sieve (10M)

~43x vs Ruby

Sieve of Eratosthenes · count = 664,579

C (gcc -O3) 11.21 ms
H (hlc -O3, @[nogc]) 13.75 ms
Ruby (MRI) 585.97 ms

About 1.23x C and ~42.6x faster than Ruby. The ~2.5 ms gap to C comes from H's arena eagerly zeroing the 10 MB buffer while C's calloc requests zeroed OS pages directly.

N-Body (2M steps)

Matches gcc -O3

5-body gravitational · @[nogc] value structs

H (hlc -O3, @[nogc]) 75.37 ms
C (gcc -O3) 76.00 ms

Written idiomatically in H with struct Vec3 and overloaded +, -, and * operators inside with_arena. LLVM inlines the operators and keeps fields in registers.

JSON Roundtrip (20k)

~2.0 μs / op

Parse + stringify · pure-H std/json (GC)

H (hlc -O3, default GC) 40.29 ms

Parses a nested JSON document into GC-managed objects and serializes it back 20,000 times using only pure-H std/json — no C JSON library underneath.

Standard Library & Tooling

Everything you need to build, format, test, and edit H.

The toolchain ships with a native compiler, canonical formatter, lightweight editor language server, C++ wrapper generator, test runner, and batteries-included standard library.

hlc Compiler

Compiles .hl files and h.toml projects to native binaries via LLVM, supports hlc run, and emits -g DWARF debug info for gdb and lldb.

hl-lsp Zero LLVM

Provides real-time type diagnostics, hover signatures, go-to-definition, outline symbols, and completions by sharing H's pure-H typechecker with zero libLLVM dependency.

hlfmt Formatter

Formats H code into one clean 2-space style with --write for local editing and --check for CI pipelines.

hl-bindgen-cpp C++ Bridge

Reads C++ headers and generates exception-safe extern "C" shims alongside idiomatic H wrapper classes and template bindings.

hlc test Test Runner

Discovers *_test.hl files and def test_*() functions, builds a native test binary with std/test, and reports pass/fail status.

VS Code & Neovim Editors

Ready-to-use TextMate grammar, block folding, Neovim filetype setup, automatic hl-lsp attachment, and :HFormat included in editors/.

Standard Library (std/)

Browse module reference →

Core & Data

std/str strings std/math math std/map Map & Set std/result Result std/json JSON

System & CLI

std/fs files std/path paths std/env env vars std/args CLI flags std/process processes std/time timers

Networking & Concurrency

std/net TCP & UDP std/http HTTP/1.1 std/thread threads & channels

Testing & Foreign Runtimes

std/test assertions std/interop/druntime D GC std/interop/objc libobjc std/interop/dotnet CoreCLR
Install & Build

Build H from source in minutes.

Bootstrap the self-hosted compiler once with Zig, install the standalone binaries to ~/.local, and run hlc from any folder.

1. Build & install to ~/.local
$ git clone https://github.com/buntatoes/h-lang.git
$ cd h-lang
# Build the self-hosted H compiler, pure-H runtime, and tools
$ zig build self-host
$ zig build tools
# Install hlc, hlfmt, hl-lsp, hl-bindgen-cpp, and std/ to ~/.local
$ ./scripts/install.sh
2. Run your first program
# Ensure ~/.local/bin is in your PATH
$ hlc run examples/hello.hl
3. Run tests & fixed-point verification
# Bootstrap, self-hosting, and interop tests
$ zig build test
# Verify the self-hosted compiler reproduces itself bit-for-bit
$ zig build fixed-point
# Run the pure-H standard library and language test suite
$ zig build htest