Skip to content

Hydrogen (Hylang)

Development reference from Hylang-Compiler. Commands and source paths on this page are relative to that repository checkout. For current task status, use the development project.

Hydrogen is a C#-inspired language with classes, methods, managed strings and arrays, and explicit low-level facilities. Source files use .hy; project manifests use .hyproj.

The Hydrogen-written compiler produces Linux x86-64 ELF, Windows x64 PE32+, and macOS x64 Mach-O executables from the same direct language backend, constrained x86-64 UEFI images, and can compile itself. The C++ SDK provides additional language features, an interpreter, packaging, formatting, and editor integration. Choose the tool according to the features your program needs.

Tool Use it for Output or execution
hydrogen-stage1 (Hydrogen) Direct native compilation, source/project checking, IR inspection, UEFI boot/kernel images, and project scaffolding Linux x64 ELF, Windows x64 PE32+ console executable, macOS x64 Mach-O, constrained uefi-x64 PE32+, raw AUKR kernel, checked AUEX .exec, or narrow AUN1; no external compiler or linker for these outputs
hy (C++ SDK) Build/run/test/check/fmt/new/package/LSP workflows; UEFI console proof Interpreter, host C backend, constrained uefi-x64 PE32+, or verified macos-arm64 console output through Apple’s clang on macOS
hyrun Direct interpreted execution Shares the SDK semantic pipeline
hyc build Compatibility build command Host C backend, executables or static libraries; also accepts macos-arm64 on macOS

See the language and tool reference and native compiler guide for the supported features of each route. For runtime performance measurements and planned work, see the optimisation notes. The runtime comparison harness times equivalent Hydrogen, C, C++, and Rust programs. The security review records confirmed issues and hardening work.

The Hydrogen Development project tracks the 0.2.0 development target. The 0.9.0 cross-platform qualification work now includes an Intel macOS runtime that passed self-hosting, byte-identical compiler output, argv, console, Unicode and binary file I/O, garbage collection, and process execution on a GitHub-hosted macOS runner. The macOS archive, website installer fixture, package workflow, update, and uninstall checks also passed on macOS. The next release gate is a tagged archive and live install from published assets. Native Apple Silicon console output is verified through the C++ bootstrap compiler’s macos-arm64 target. Native AppKit packaging and interaction also passed on Apple Silicon; self-hosted direct arm64 output remains open. Track this in #146. Fixed-width bitwise operators, integral compound assignment, increment/decrement, conditional expressions, null coalescing, null-conditional access, foreach over arrays and strings, interpolated strings, switch statements and expressions, and range-based slicing are implemented across the SDK, Linux native, and Windows native paths under Wine. The top ten language features are tracked on that project. The next 0.2.0 language target is full-width unsigned hexadecimal literals; real Windows-host validation remains an open release gate. The SDK self-hosting workspace and formatter checks are required CI gates; the local CTest suite also covers preservation of the Windows manifest output name. Format 2 project manifests now accept arrays of quoted strings spread across lines. The self-hosted compiler builds collection projects and allows an OS project to include one; Australis’s application collection builds all twelve listed applications. Full OS integration remains pending while its separate driver, filesystem, and userland project manifests are being reorganized. Native text assembly now has a byte-buffer builder sample for Linux and Windows; its FromBytes finishing intrinsic is native only. The native collector now groups adjacent dead-span releases on Linux; the GC profiling notes retain its before/after measurements. The 0.8.0 optimisation work has completed proven packed-array bounds elimination for guarded native loops. Broader local register and loop code generation in #127 remains the next performance target. Guarded string scans, register-held loop values, and direct packed-array accesses have improved the measured cases. Linux small-object allocation now skips clearing never-used mapped slots and clears recycled slots through their requested payload; paired node timings improved. A guarded zero-based loop index now uses the nonnegative constant division and remainder path, with signed handling retained elsewhere. Adjacent immediate int arithmetic now keeps intermediate results at 32-bit width, reducing one sign extension in the array fill case. The latest six-case check meets the slowest C/C++/Rust comparison for log, CSV, and bytes; array, loop, and nodes remain above it. The latest 31-run snapshot uses a freshly rebuilt stage-1 compiler and is shown first on the benchmark page. A tested loop-tail branch layout did not improve speed and was reverted. A guarded modular array fill now keeps a running remainder when the loop bound excludes signed overflow; its paired array result improved from 85.57 to 79.06 ms. The latest full snapshot still misses the array target by 1.39 times, so further fill-loop code generation is the next 0.8.0 performance target. #127 and #128 remain In Progress under the 0.8.0 performance target. The development project still tracks 0.2.0 language work and the 0.1.0 release qualification gate; published release assets and a live Windows install remain open. Native source package work for the 0.5.0 target is in progress under #111. The native CLI now packs and adds local source archives, removes direct dependencies, resolves exact transitive dependencies from .hylang/packages, and verifies the SHA-256 hashes in hy.lock during builds. It can search the curated static registry, fetch a pinned package and its transitive dependencies, restore a project from its lockfile, and upgrade a direct dependency to an explicit version. Windows release packaging and the hy.cmd launcher have a Wine-checked candidate. The PowerShell lifecycle and website installer pass fixture tests on GitHub-hosted Windows runners. Published installer-ready assets and a live Windows install from those assets remain open release gates.

The Development HYUI AppKit renderer measures wrapped text at the available column width, sizes panels from their contents, and places native controls in a vertically scrolling document. Rows and grids reflow when the window is resized; controls retain their parents and backend event bindings. Label roles distinguish titles, headings, and captions. This fixes the overlapping controls and empty space seen in samples/ui_studio/Studio.hyui on macOS.

The macOS layout regression checks the sample at 1120, 800, and 360 pixels, including sibling overlap, parent bounds, wrapped text, nested rows, scrolling, repeated resizing, backend text updates, and hidden controls. Run it alongside the sample’s SDK backend integration after configuring Qt Core 6.8 or newer:

Terminal window
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DHYDROGEN_BUILD_UI=ON
cmake --build build --target hy hyui hyui_appkit_tests --parallel
ctest --test-dir build -R '^hyui_(appkit_layout|sdk_integration)$' --output-on-failure

This completes the Studio layout repair within the current development work; it does not change the milestone versions above. The complete shared contract suite now accepts canonically equivalent Unicode argument representations on macOS while preserving its text and shell-metacharacter checks. Packaged application checks on the target architectures remain a qualification gate. Tagged release assets, live installation from those assets, native Apple Silicon code generation, and the other release gates above still require their own validation.

Development HYUI now includes menus, tabbed pages, single-selection lists and tables, radio groups, local images, and asynchronous native message dialogs. The Studio sample’s Control gallery tab demonstrates the new controls; its Studio and Help menus navigate the tabs and open the About dialog. The existing development milestone versions still apply to this toolkit work.

HYUI P0 input and interaction work is tracked in #178 under the existing 0.5.0 native developer workflow target. The project’s current development version remains 0.2.0. Secure PasswordInput is implemented and has passed native UI CI on all three platforms in run 41363539105. Native open, save, and folder pickers are implemented and passed the local contract, GTK interaction, and relocated SDK package tests, plus the Linux, macOS, and Windows native UI jobs in run 41366091262. Menu command keyboard accelerators, context menus, text clipboard commands, toolbar commands, and anchored text popovers have passed native UI CI on all three platforms. Native view teardown hardening and GTK popover focus/ownership corrections passed three-platform native UI jobs in run 41413381471. The native teardown and callback cleanup slice is complete. Independent windows and broader ownership, focus, keyboard and accessibility consistency remain P0 work. The next toolkit targets are the remaining windows, controls and data models. The previously completed controls passed on Linux, Windows, and macOS in the pinned CI run. Broader package qualification and the release gates above remain open.

The WinUI host now cancels an active Hydrogen backend process when its window closes, alongside stopping timers and dismissing native dialogs. The Windows native interaction job in run 41468089397 exercised a live process during disposal. That run also passed the AppKit and WinUI native runtime export and application packaging jobs after correcting macOS executable permissions and Windows reparse-point detection. A local self-hosted Stage 1 build and macOS cross-package fixture passed. The full workflow completed successfully in run 41468089397. The Windows SDK export job in run 41470704541 also passed a real junction rejection check after packaging the normal Studio assets. The AppKit native interaction, reviewed screenshot, and SDK integration jobs in run 41477764976 passed after preserving window content height when the native toolbar appears. Multiple windows and broader lifecycle ownership remain P0 gates.

P0 interface HYUI v1 behavior Native mapping and status
SearchInput text, placeholder, onChange, and onSubmit have the same state and event meaning as Input. Read it with Application.Value(args, id) and update it with Application.SetText(id, text). 🟢 GtkSearchEntry on Linux, NSSearchField on macOS, and WinUI AutoSuggestBox with a search icon on Windows. Native CI passed.
PasswordInput placeholder, onChange, and onSubmit; shared visible, enabled, and accessibleName. Read the secret only in the field’s own event with Application.SecretValue(args, id). No text or value attribute, mutable property, or normal Application.Value snapshot is provided. 🟢 Native GtkPasswordEntry, NSSecureTextField, and WinUI PasswordBox passed the three-platform native interaction and appearance jobs in run 41363539105.
FilePicker `mode=“open save
MenuItem shortcut Optional shortcut="Primary+K" or shortcut="Primary+Shift+K" on a MenuItem with onClick; keys are A–Z or 0–9. Shortcuts must be unique within a document. Primary maps to Command on macOS and Control on Windows/Linux, and invokes the same Hydrogen handler as the menu command. 🟢 Native AppKit menu key equivalents, WinUI KeyboardAccelerator, and GTK global GtkShortcutController passed three-platform native CI in run 41408262483.
ContextMenu Declare as a direct child of Window with target="controlId" and one or more MenuItem children. The target must be a visual control and may have only one context menu. Menu commands use ordinary text, checked, enabled, visible, and onClick state and events. Context items do not declare global shortcut bindings. 🟢 Native GtkPopover with right-click and menu-key gestures, AppKit NSView.menu, and WinUI ContextFlyout passed three-platform native CI in run 41408262483.
Clipboard Declare a nonvisual direct child of Window with id and onRead. Application.ClipboardWrite(id, text) writes UTF-8 text; Application.ClipboardRead(id) requests the current text and sends onRead. Read it with Application.Value(args, id) in that event; clipboard contents are omitted from other event snapshots. Nontext content reads as an empty string. Text is limited to 16 KiB. 🟢 Native GDK clipboard, AppKit NSPasteboard, and WinUI clipboard adapters passed three-platform native CI in run 41408262483.
Toolbar / ToolButton Declare one Toolbar as a direct Window child with one or more ToolButton children. Each button requires text and onClick and supports visible, enabled, accessibleName, and tooltip. The toolbar supports visible and enabled for the entire command surface. 🟢 Native libadwaita header commands, AppKit NSToolbar, and WinUI CommandBar passed local contract/GTK and three-platform native interaction jobs in run 41409632272.
Popover Declare a direct Window child with required id, target and text, optional open (default false) and onClose. target names a Button; the button’s onClick opens the popover through the Hydrogen backend. Application.SetOpen shows or hides the anchored text, and Application.SetText updates it. Native dismissal sets open false and dispatches onClose; backend closure does not dispatch it. 🟢 Native GtkPopover on GtkMenuButton, AppKit NSPopover, and WinUI Flyout passed contract, GTK/package, and all three native UI jobs in run 41413381471. GTK focus and ownership hardening also passes a local fatal-critical native test. Popover content is text-only at this stage; rich content remains a P0 gate.
ScrollView Vertical container with ordinary HYUI children; height defaults to 200 and gap to 12. visible, enabled, accessibleName, and tooltip use the shared visual properties. The height must be positive. 🟢 GtkScrolledWindow on Linux, NSScrollView on macOS, and WinUI ScrollViewer on Windows. Native CI passed.
TreeView items is a preorder depth:label hierarchy; value is its zero-based row index and onChange returns that index. Application.SetItems and SetValue update the model and selection atomically; an implicit stale selection clamps after a shrink. 🟢 Native GTK4 tree view, AppKit NSOutlineView, and WinUI TreeView passed shared contracts, three-platform native interaction and reviewed screenshots, and Stage 1–3 single-file GTK4 generation in run 43358715272.
tooltip Optional static text on widget-backed controls and layout containers. Menus, dialogs, and nonvisual elements reject it. It is not a mutable backend property. 🟢 Native GTK tooltip, AppKit toolTip, and WinUI ToolTipService. Native CI passed.

Studio reveals its search field and a scrollable template-details area after choosing a template. The search term is sent to SearchTemplates on edits and SubmitSearch on submission; its Hydrogen backend shows the term in the gallery. The initial gallery appearance and reviewed screenshot baselines are unchanged. Search does not yet filter the static ListBox data. The scroll area contains a native button whose action updates the gallery through the Hydrogen backend. Native toolbar commands appear after a template is selected. The next UI target is multi-window lifecycle, custom-content dialogs, tree-backed collections, drag and drop, and observable data-model updates in #179. The remaining P0 foundations, P1 controls, and P2 integrations in the UI handover are still open; the project issues record implementation and verification status.

Studio also reveals a native password field after choosing a template. Its PasswordEdited and CheckPassword handlers read the secret through Application.SecretValue; the gallery displays only the length and a match result. The host passes a path to a per-event private temporary file instead of passing the secret in process arguments or the broad UI state snapshot. The host removes the file when the handler exits or fails, limits it to 16 KiB, and sends it only for the password field’s own event. As with any application secret, the Hydrogen handler must avoid printing or persisting it. The temporary file can be read by processes with the same operating-system user privileges while the event is active; this is the remaining transport boundary.

Local Linux checks pass the shared contract suite, Studio Hydrogen backend build, SDK integration, native GTK interaction/layout suite, and relocated package suite. The local screenshot comparison differs from the reviewed Ubuntu 24.04 baseline on this newer Linux host; no baseline or threshold was changed. The pinned three-OS native UI jobs passed their visual and interaction checks on the unchanged baselines.

Element Attributes and behavior
MenuBar, Menu, MenuItem One MenuBar directly inside Window; each Menu has text and MenuItem children. Items use text, onClick, and optional checked.
Tabs, Tab Tabs contains Tab pages with title and ordinary layout children. value selects a zero-based page; onChange handles selection.
ListBox Pipe-separated items, a selected value, optional height (160 by default), and onChange.
Table Pipe-separated columns; newline-separated rows with pipe-separated cells. Each row must match the column count. value, height, and onChange work as for lists.
RadioGroup Pipe-separated items, selected value, and onChange.
Image A local source relative to the .hyui file and optional height (72 by default). Images preserve their aspect ratio; PNG is used by Studio. Include image folders in ui_assets when packaging.
Dialog A direct Window child with title, text, one to three pipe-separated buttons (default OK), open, selected button value, and onClose.

Collections and page definitions are declared in XML. Their selected indices can be read with Application.Value(args, id) and changed with Application.SetValue(id, index); indices outside the declared range are rejected. Use 
 for table row separators inside an XML attribute. The item/row data is static in this first implementation. Remote image URLs and paths outside the view’s asset directory are not supported.

Application.SetOpen("confirmation", true) opens a dialog without blocking the host event loop. Dismissing it sets open to false and sends onClose a snapshot whose dialog value is the zero-based button index. Closing through the window controls maps to the last button; backend-driven closure does not dispatch a new close handler. Dialog text can be changed before opening. Menus, controls, and dialogs use AppKit on macOS, GTK on Linux, and WinUI on Windows.

The macOS regression exercises real menu/tab actions, radio/list/table selection, bundled image loading, and a native confirmation sheet through the Hydrogen sample backend. Shared contract tests cover valid nesting, selection ranges, malformed tables, image paths, and atomic backend updates. The native UI CI suites below exercise interaction and appearance on all three host OSes. Linux also passes packaged-app build, relocation, compiler-free launch, callbacks, saving, and screenshot checks. Installer qualification and packaged-app checks on the other hosts/architectures remain separate gates, alongside the release and architecture gates above.

Button and other event handlers can change existing controls without restarting the app. For example, a button declared with onClick="Start" can update a label, disable itself, reveal a predeclared panel, or switch tabs:

if (Application.Handler(args) == "Start") {
Application.SetText("status", "Working...");
Application.SetEnabled("start", false);
Application.SetVisible("details", true);
Application.SetValue("pages", 1);
}

The native host applies the response and reflows the layout. Use Application.SetRunning for timers/spinners and Application.SetOpen for dialogs. Studio already demonstrates live text, selection, enabled-state and progress changes; the native CI suites drive those actions through its compiled Hydrogen backend. Element creation/removal and replacement of list/table data are not exposed by this first API; declare conditional sections in XML and toggle their visibility.

The Hydrogen CI workflow launches the real UI on three pinned runner families: AppKit on macos-15, system GTK 4/libadwaita on ubuntu-24.04 under a D-Bus session and Xvfb, and a self-contained WinUI build on windows-2025. The WinUI interaction harness is compiled only with HydrogenUiTests=true; shipping builds do not include its test entry point.

Each native suite drives actual control actions and selection signals through the Hydrogen Studio backend. Coverage includes menus, tabs, lists, tables, radio groups, images, dialog results, form editing, progress, cancellation, timer completion, and saving the edited text. Native layout checks reject intersecting siblings and content outside its parent, and verify that the workspace and nested rows stack on narrow windows.

The suites capture Workspace and Control gallery at 1120, 800, and 360 pixels, plus scrolled Workspace/Control gallery views and the native confirmation dialog: nine images per OS. Fixtures request a height of 600 pixels; GTK’s client captures exclude its 10-pixel frame inset, while AppKit and WinUI capture the full 600-pixel content viewport. Test fixtures use a fixed light theme; AppKit disables backdrop material for repeatable images. Screenshots are compared with the reviewed per-OS PNGs in tests/ui/golden/<platform>/. Each capture comes from its corresponding OS runner. AppKit and WinUI capture the content area, excluding the system title/menu bars; GTK captures its native client-side header too. Inspecting a Linux artifact on a Mac does not change the renderer used by the Mac build. The comparator rejects blank images, clipped/unrendered client areas, and size changes, then compares a 224-by-180 reduction with a maximum mean RGB difference of 0.035 and at most 12% of pixels changing by more than 35/255 in any channel. These tolerances allow small font-rasterization differences; the independent geometry checks catch overlap and clipping. A separate negative test proves that blank, resized, and displaced content fails comparison.

The Linux checks also enforce the requested window width and declared image height, and require scrolling to reveal the final controls. They caught GTK row minimum-width feedback, incorrect wrapped-text height, hidden-page whitespace, and oversized image allocation. Rows measure their native contents at the available width inside viewports; native stack/switcher tabs measure the selected page, and images use bounded native textures. The Windows SDK build sets NOMINMAX and avoids the Windows small macro collision. Its C backend uses Clang for the existing GNU C expression extensions, while the SDK executable itself is built with MSVC. The Windows runner configures a supported virtual desktop mode of at least 1280 by 800 so the wide client is rendered, and yields to native text events before saving.

Every OS job uploads its screenshots, geometry/state report, visual difference images, and logs for 14 days, including failed runs. Missing baselines fail; CI never silently accepts new images. To review a deliberate visual change, download that run’s actual PNGs, inspect the wide and narrow layouts and dialog, copy approved images into the matching golden directory, and commit them with the change. Keep the pinned runner, light fixture, and expected dimensions consistent; do not substitute a screenshot from another OS. Older runs of the same branch are cancelled when a newer commit arrives.

The initial reviewed baselines came from these real native runner captures:

Platform Renderer / runner Capture run
macOS AppKit / macos-15 80acba9
Windows WinUI / windows-2025 ca43c0a
Linux GTK / ubuntu-24.04 8da67e6

These initial captures intentionally fail when their reviewed baseline is missing; subsequent runs must compare successfully against the committed PNGs. All three native interaction/layout suites and all 27 reviewed screenshot comparisons passed for 10d1550 in the qualification run, alongside compiler/bootstrap, macOS runtime, and Windows lifecycle checks. The optional published-Windows-release smoke test was not requested in that run.

The platform runner can also be invoked locally after building its native driver:

Terminal window
python -m pip install Pillow==12.0.0
python tools/hyui/ui_ci.py --platform macos \
--driver build/tools/hyui/hyui_appkit_tests --compiler build/hy \
--artifacts build/ui-artifacts

On Linux use hyui_gtk_tests inside dbus-run-session -- xvfb-run; Windows uses the published Hyui.WinUI.exe built with HydrogenUiTests=true and WindowsAppSDKSelfContained=true, plus a native SDK compiler in a Visual C++ developer environment. Release publication, installer qualification, and native Apple Silicon code generation remain separate gates; UI checks do not change the development milestone versions above.

hy build, hyc build, and the self-hosted hy build update one terminal line per action. The braille spinner and bar show overall build progress, with a separate percentage for the active action. The bar uses up to 60 characters and shrinks in narrow terminals; long interactive progress text ends in ... instead of wrapping. Terminal width is checked on each redraw, so resizing takes effect during a build. The line becomes its 100% result when that action completes. Overall progress counts completed milestones, while lexing and parsing use source and token positions for their action percentages. Stages without measurable internal work stay at 0% until completion. The SDK spinner animates while a terminal build is busy. Redirected output uses full plain text without terminal escape codes.

Use --hide-progress, --hide-spinner, or --hide-log to remove individual parts. For example, hy build MyApp/MyApp.hyproj --hide-progress keeps the spinner and messages. Using all three flags leaves the normal output path or wrote result, plus any errors.

The packaged native compiler for Linux and macOS x86-64 includes a shell launcher and safe lifecycle commands. These are not commands of the C++ development SDK binary (./build/hy) or an unbundled hydrogen-stage1 binary.

Terminal window
hy --version
hy update-check
hy update
hy update --force
hy uninstall
hy uninstall --force
hy remove --force # alias for uninstall

The launcher detects APT/dpkg, DNF/YUM/RPM, Pacman and Homebrew ownership and delegates package-management operations. Manual installations use an included file manifest and GitHub Releases checksums/digests; they refuse to touch any unmanaged files. --force skips prompts, but never disables safety checks.

This is available in newly packaged releases, not in old standalone compiler binaries. See Linux release installation details and Windows release installation details. The isolated Linux lifecycle checks run with ctest -R hy_release_lifecycle --output-on-failure. The Windows ZIP layout, hy.cmd launcher, and compiler delegation run under Wine with ctest -R hy_stage1_windows_release --output-on-failure. GitHub Actions also exercises the PowerShell lifecycle on a Windows runner; the published release smoke test runs manually after installer-ready assets exist.

The self-hosted compiler accepts exact package versions in a format 2 project:

[dependencies]
example = "1.0.0"

The package library must declare the same version and [package] id, and live at .hylang/packages/example/1.0.0/example.hyproj beneath the project. hy package pack example.hyproj -o example.hypkg creates a source-only archive. hy package add App.hyproj example.hypkg installs a local archive. For the curated website registry, use hy package search math, hy package add App.hyproj [email protected], hy package restore App.hyproj, or hy package upgrade App.hyproj [email protected] when that version exists. hy package remove App.hyproj example removes the direct dependency and refreshes the lock. hy package lock App.hyproj records a pre-existing local package tree when each package directory also contains package.hypkg. Builds verify the lock and fail if package files change. Commit hy.lock; the .hylang/packages directory is a project-local cache. Development can point at another HTTPS or local-file registry with --registry <origin>.

The release candidate command compiles the current self-hosted compiler source for Linux, Windows, and macOS x64, then creates installer-compatible archives and their .sha256 sidecars. Pass a verified self-hosted compiler:

Terminal window
RELEASE_VERSION=alpha-0.0.3
cmake -DSOURCE_DIR="$PWD" -DHOST_COMPILER="/path/to/verified/hy" \
-DVERSION="$RELEASE_VERSION" -DRELEASES_DIR="$PWD/releases" \
-P cmake/MakeHydrogenReleaseCandidate.cmake

The command stages outputs until all three platforms build and their archive checksums pass. It refuses to overwrite existing assets unless -DFORCE=ON is set. Australis is not included: its current AUEX/AUN1 targets are constrained OS program formats, and there is no self-hosted compiler CLI project that runs on Australis.

If CMake is already configured with HYDROGEN_RELEASE_VERSION and HYDROGEN_RELEASE_BINARY, use cmake --build build --target hydrogen_release_candidate.

To package only a previously verified Linux compiler at safe/hy, run:

Terminal window
RELEASE_VERSION=your-next-version
cmake -DSOURCE_DIR="$PWD" -DVERSION="$RELEASE_VERSION" -P cmake/PackageHydrogenRelease.cmake

This writes releases/hydrogen-<version>-linux-x86_64.tar.gz and its adjacent .sha256 checksum. The archive contains bin/hy, a release README, build metadata, and SHA256SUMS for the executable. The command refuses to overwrite an existing release; pass -DFORCE=ON only when intentionally rebuilding it.

If CMake is already configured, the Linux-only target is:

Terminal window
cmake -S . -B build -DHYDROGEN_RELEASE_VERSION="$RELEASE_VERSION"
cmake --build build --target hydrogen_package_release

To build and package the Windows x64 compiler from the same verified self-hosted compiler, run:

Terminal window
cmake -DSOURCE_DIR="$PWD" -DHOST_COMPILER="/path/to/verified/hy" \
-DVERSION="$RELEASE_VERSION" -DRELEASES_DIR="$PWD/releases" \
-P cmake/MakeHydrogenWindowsRelease.cmake

This builds the Windows compiler executable, checks its PE header, then writes releases/hydrogen-<version>-windows-x86_64.zip and its .sha256 sidecar. Like the Linux script, it refuses to overwrite an existing release unless -DFORCE=ON is set. The ZIP contains bin/hy.cmd, libexec/hy-core.exe, a PowerShell lifecycle helper, and the same manifest/checksum contract as the Linux archive. Keep all platform archives and their sidecars together for an installer-compatible GitHub release.

For a macOS x64 archive only, run cmake/MakeHydrogenMacOSRelease.cmake with the same SOURCE_DIR, HOST_COMPILER, VERSION, and RELEASES_DIR values. It checks the Mach-O header and writes hydrogen-<version>-macos-x86_64.tar.gz plus its .sha256 sidecar. The equivalent configured target is hydrogen_package_macos_release.

If CMake is already configured with HYDROGEN_RELEASE_VERSION and HYDROGEN_RELEASE_BINARY, the equivalent target is cmake --build build --target hydrogen_package_windows_release. To package an already-built Windows executable without rebuilding it, use cmake/PackageHydrogenWindowsRelease.cmake with -DINPUT_BINARY=<path>.

Run these commands from this repository’s root. The SDK requires CMake 3.20 or newer and a C++20 compiler. Its executable builds also require a host C compiler; static-library builds require an archiver. The direct native compiler targets Linux, Windows, and macOS x64.

Terminal window
cd /path/to/Hylang-Compiler
# Build the C++ stage 0 compiler.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target hy --parallel
./build/hy --help
# Use stage 0 to produce the temporary Hydrogen bootstrap compiler.
mkdir -p build/self_hosting
rm -f build/self_hosting/hydrogen-bootstrap
./build/hy build samples/self_hosting/Hydrogen.Compiler.Cli/Hydrogen.Compiler.Cli.hyproj -o build/self_hosting/hydrogen-bootstrap
chmod +x build/self_hosting/hydrogen-bootstrap
# This is the temporary Hydrogen bootstrap compiler.
./build/self_hosting/hydrogen-bootstrap --help
# Bootstrap compiler -> stage 1.
rm -f build/self_hosting/hydrogen-stage1.pending
./build/self_hosting/hydrogen-bootstrap build ./samples/self_hosting/Hydrogen.Compiler.Cli/Hydrogen.Compiler.Cli.hyproj -o ./build/self_hosting/hydrogen-stage1.pending
chmod +x build/self_hosting/hydrogen-stage1.pending
mv build/self_hosting/hydrogen-stage1.pending build/self_hosting/hydrogen-stage1
# This is stage 1.
./build/self_hosting/hydrogen-stage1 --help
# Stage 1 -> stage 2.
rm -f build/self_hosting/hydrogen-stage2.pending
./build/self_hosting/hydrogen-stage1 build ./samples/self_hosting/Hydrogen.Compiler.Cli/Hydrogen.Compiler.Cli.hyproj -o ./build/self_hosting/hydrogen-stage2.pending
chmod +x build/self_hosting/hydrogen-stage2.pending
mv build/self_hosting/hydrogen-stage2.pending build/self_hosting/hydrogen-stage2
# This is stage 2.
./build/self_hosting/hydrogen-stage2 --help
# Stage 2 -> stage 3.
rm -f build/self_hosting/hydrogen-stage3.pending
./build/self_hosting/hydrogen-stage2 build ./samples/self_hosting/Hydrogen.Compiler.Cli/Hydrogen.Compiler.Cli.hyproj -o ./build/self_hosting/hydrogen-stage3.pending
chmod +x build/self_hosting/hydrogen-stage3.pending
mv build/self_hosting/hydrogen-stage3.pending build/self_hosting/hydrogen-stage3
# This is stage 3.
./build/self_hosting/hydrogen-stage3 --help
# Stage 2 and stage 3 should be byte-identical.
sha256sum build/self_hosting/hydrogen-stage2 build/self_hosting/hydrogen-stage3
cmp build/self_hosting/hydrogen-stage2 build/self_hosting/hydrogen-stage3

The native target initially uses the SDK’s C backend to create a seed, then Hydrogen’s own backend compiles the complete compiler CLI project and its referenced libraries. The resulting build/self_hosting/hydrogen-stage1 has no C/C++ toolchain dependency when compiling supported programs.

For a manual SDK build:

Terminal window
mkdir -p build
c++ -std=c++20 -Wall -Wextra -Wpedantic -Iinclude src/hylang.cpp src/hy_main.cpp -o build/hy
c++ -std=c++20 -Wall -Wextra -Wpedantic -Iinclude src/hylang.cpp src/hyrun_main.cpp -o build/hyrun
c++ -std=c++20 -Wall -Wextra -Wpedantic -Iinclude src/hylang.cpp src/hyc_main.cpp -o build/hyc

Save this as hello.hy:

namespace Hello {
public class Program {
public static int Twice(int value) {
return value * 2;
}
public static int Main(string[] args) {
string name = "World";
if (args.Length > 0) { name = args[0]; }
System.Console.WriteLine("Hello, " + name);
System.Console.WriteLine(Twice(21));
return 0;
}
}
}

Compile directly with Hydrogen:

Terminal window
./build/self_hosting/hydrogen-stage1 check hello.hy
./build/self_hosting/hydrogen-stage1 compile hello.hy -o build/hello
chmod +x build/hello
./build/hello Hydrogen

Expected output:

Hello, Hydrogen
42

Native output files need execute permission. Compilation failures return a nonzero status and do not create or overwrite the output; check that status before running an existing artifact.

The self-hosted compiler can emit a bootable x86_64 UEFI PE32+ application. Its Main method can call System.Uefi.ClearScreen() before console output, call System.Uefi.Await() to wait for and consume one keyboard event, and contain multiple System.Console.WriteLine calls with ASCII string literals. A UEFI program may also call System.Uefi.StartImage("\\EFI\\AUSTRALIS\\KERNEL.EFI") to read an EFI application from the same FAT volume and start it through UEFI boot services. For the first freestanding kernel handoff, call System.Uefi.ExitBootServices(), System.Kernel.MemoryMap.Initialize(), System.Kernel.Memory.Initialize(), System.Kernel.VirtualMemory.Initialize(), System.Kernel.VirtualMemory.ApplyPolicy(), optional System.Kernel.Memory.AllocatePage() calls, System.Kernel.Heap.Initialize(), optional System.Kernel.Heap.Allocate(<literal-byte-count>) calls, System.Kernel.Framebuffer.Initialize(), and literal System.Kernel.Framebuffer.WriteLine(<text>) calls, then System.Kernel.Halt(). The generated image captures a final UEFI memory map, chooses the largest EfiConventionalMemory descriptor, reserves and clears its first 4 KiB page, and writes the resulting physical-page range to a writable KernelBootInfo record. It reserves 64 descriptor slots, retries the final GetMemoryMap/ExitBootServices pair up to eight times, then copies every present PML4, PDPT, PD, and PT page into allocator pages, records the new root, and switches CR3 to it. Leaf mappings retain their existing physical frames and attributes. The PE32+ image has a zero image base and RIP-relative internal references. Post-handoff Hydrogen code receives the record pointer in RDI; its state is 127 after the framebuffer console is active. An interrupt-enabled kernel then calls Gdt.Initialize(), Idt.Initialize(), Interrupts.Initialize(), and Timer.Initialize(). It may call Pci.Initialize(), Mmio.Initialize(), Dma.Initialize(), and one or more literal Dma.AllocatePages(<1..1024>) calls before it enables interrupts and idles. PCI enumeration uses configuration mechanism #1 at ports 0xcf8 and 0xcfc, records the first xHCI, AHCI, and NVMe functions, and maps a guarded, uncached, non-executable 64 KiB high register aperture for each valid memory BAR. DMA pages are contiguous, zeroed, and selected from conventional memory below 4 GiB. The compiler reserves the literal DMA requests from that interval; if the reserved slice overlaps the main page allocator, that slice is removed before allocations begin. Each AllocatePage() call reserves and zeros one 4 KiB page and writes its physical address to KernelBootInfo + 72. Heap.Initialize() adds a zeroed heap page; Heap.Allocate() accepts a literal size from 1 through 1 MiB, aligns it to 16 bytes, grows the heap with contiguous physical pages, and writes its address to KernelBootInfo + 104. This bootstrap heap is monotonic and does not free or reuse allocations. After a DMA allocation, the interrupt kernel may call System.Kernel.Storage.Initialize() before Interrupts.Enable(). The emitted transport prefers a discovered NVMe controller, using depth-two admin and I/O queues, namespace Identify, and bounded polling reads. It falls back to AHCI READ DMA EXT when no NVMe aperture is mapped. Both paths read LBA 0, LBA 1, and the GPT primary entry array. The builder validates the protective MBR, the GPT 1.0 header and CRC, and the primary entry-array CRC; the current bootstrap accepts 512-byte logical sectors and up to 256 standard 128-byte GPT entries. It records the controller kind and first present GPT partition in KernelBootInfo ABI version 7. The image does not yet mount a filesystem. Framebuffer initialization locates GOP before ExitBootServices, stores its base, size, geometry, and pixel format in KernelBootInfo, clears the display directly after the handoff, and renders printable ASCII with an embedded 8x8 font. It accepts the standard RGB and BGR 32-bit GOP modes. The paging walker supports the normal four-level x86_64 mode; it detects LA57 and halts before replacing CR3 on a five-level firmware hierarchy. The SDK compiler’s older UEFI path still accepts only one printable ASCII WriteLine literal.

Terminal window
./build/self_hosting/hydrogen-stage1 compile tests/uefi_hello.hy --target uefi-x64 -o build/BOOTX64.EFI
file build/BOOTX64.EFI

The result is an EFI application, not a Linux ELF. The self-hosted compiler emits a PE32+ image, uses the UEFI Microsoft x64 entry ABI, writes an ASCII message as UTF-16 through the firmware OutputString function pointer, and then remains on screen. The chain-loading intrinsic uses the loaded-image, simple-file-system, and file protocols to pass an in-memory EFI application to LoadImage and StartImage. The kernel handoff collects the final memory map, materializes KernelBootInfo, invokes ExitBootServices, initializes a bootstrap physical-page range, copies every present paging-structure page into allocator-owned memory, removes the null page mapping, then halts with interrupts disabled. This target has no managed runtime, Linux syscalls, arbitrary method compilation, raw freestanding kernel-image format, or general post-handoff runtime yet.

Alternatively, interpret or build with the SDK:

Terminal window
./build/hy run hello.hy -- Hydrogen
./build/hy build hello.hy -o build/hello-sdk
./build/hello-sdk Hydrogen

Main is a static class method returning int or void, with no parameters or one string[] parameter. Its argument array excludes the executable name; an integer return supplies the process exit status. Hydrogen has no top-level statements or free functions.

An executable project can reference library projects by source closure:

format = 2
name = "Hello"
type = "exe"
sources = ["Program.hy"]
project_references = ["../Shared/Shared.hyproj"]

Paths are relative to the containing manifest. Use type = "lib" for a referenced library. The native compiler binds referenced sources together and emits one executable:

Terminal window
./build/self_hosting/hydrogen-stage1 build Hello/Hello.hyproj -o build/hello-project
chmod +x build/hello-project
./build/hello-project

For OS development, the self-hosted compiler supports type = "efi" for a UEFI application, type = "kernel" for a raw freestanding kernel image, type = "exec" for an Australis AUEX v1 program, and type = "os" for an aggregate project. The older type = "australis" spelling remains accepted for existing AUEX projects.

The AUEX backend supports scalar and string locals, assignment, arithmetic including division and remainder, comparisons, short-circuit Boolean expressions, if/else, while, for, break, and continue. System.Console.Write and WriteLine accept strings and scalar values, and System.Console.ReadLine() returns a string. System.IO.File.Exists(path) and ReadAllText(path), System.IO.File.WriteAllText(path, text), and System.Convert.ToInt32(text) use the same source API as native programs. AUEX text values are currently limited to 255 bytes. Main may return a computed integer exit code. Australis-specific file, metadata, directory, yield, and checked-memory intrinsics remain available for lower-level work. The current development AUEX backend also supports application method calls, bounded strings and byte arrays, and concurrent child processes. These calls remain software-checked inside the kernel interpreter.

Arrays such as sources and project_references can span lines, with one quoted path per line and an optional trailing comma. A collection groups independently built projects without naming the group an OS. It can also be included by an OS project. Each child still declares its own relative output.

An OS project lists component .hyproj files in project_references and has no sources of its own. Each component sets an output path relative to the build directory, such as EFI/BOOT/BOOTX64.EFI. Hydrogen compiles each component independently:

# OS.hyproj
format = 2
type = "os"
project_references = [
"Components.hyproj",
]
# In Components.hyproj: type = "collection"
# project_references = ["Boot/Boot.hyproj", "Kernel/Kernel.hyproj"]
# In Boot/Boot.hyproj: type = "efi", output = "EFI/BOOT/BOOTX64.EFI"
# In Kernel/Kernel.hyproj: type = "kernel", output = "EFI/OS/KERNEL.BIN"
Terminal window
./build/self_hosting/hydrogen-stage1 build OS/OS.hyproj -o build/efi

The output directory contains a PE32+ EFI bootloader and a separate raw AUKR kernel image ready for packaging. You can also build an efi, kernel, or exec project directly with -o pointing to its output file. Scaffold them with hydrogen-stage1 new efi <name>, hydrogen-stage1 new kernel <name>, hydrogen-stage1 new exec <name>, or hydrogen-stage1 new os <name>. Use hydrogen-stage1 new collection <name> to scaffold a collection. These project types are currently available in hydrogen-stage1.

For Windows x64, use --target windows-x64 on a source file or a format-2 type = "windows" project. Both routes produce PE32+ console programs with the same direct language subset and managed runtime APIs as Linux:

Terminal window
./build/self_hosting/hydrogen-stage1 compile tests/phase6/native_hello.hy --target windows-x64 -o build/hello.exe
./build/self_hosting/hydrogen-stage1 build tests/phase6/WindowsFullRuntime.hyproj -o build/WindowsFullRuntime.exe

The native compiler guide has the Windows runtime and verification details.

Australis OS additionally loads bounded AUN1 machine-code children in hardware ring 3. Hydrogen’s exec backend emits AUEX; a separate native project emits AUN1 version 2 for a single static Main(string[] args) with ASCII literal System.Australis.Terminal.Write calls and a literal integer return status. The native target has no general-purpose runtime yet. See the Australis kernel completion criteria for OS-side loader status.

SDK projects additionally support workspaces, test projects, local package dependencies, caching, and static-library artifacts. Useful SDK commands:

Terminal window
./build/hy new app MyApp
./build/hy check MyApp/MyApp.hyproj --json
./build/hy build MyApp/MyApp.hyproj
./build/hy run MyApp/MyApp.hyproj -- argument
./build/hy fmt MyApp --check

The direct native route supports classes, inheritance, interfaces, virtual dispatch, structs, overloads, static and instance fields/methods, constructors, recursion, enums, signed and unsigned integer widths, bool, strings, arrays, var, if/else, while, for, break, continue, and returns. int is signed 32-bit. Strings have byte-based length/indexing; indexing returns a one-byte string. Native literals accept ASCII and common escaped control characters; file contents and arguments preserve raw bytes.

The SDK and native compiler support fixed-width integer &, |, ^, ~, <<, and >>. Shift counts are masked by the left operand’s width minus one; signed right shifts preserve the sign bit, while unsigned right shifts fill with zero. Integral lvalues also support +=, -=, *=, /=, %=, &=, |=, ^=, <<=, and >>=. The assignment returns the stored value and evaluates an indexed or field target once. Compound shifts use the target’s integer width. Prefix and postfix ++ and -- work on integral lvalues. Prefix returns the new value; postfix returns the old value. Both evaluate the target once. The conditional condition ? whenTrue : whenFalse expression requires a bool condition and compatible branch types; only the selected branch runs. Null coalescing with left ?? fallback accepts references, evaluates the left once, and evaluates the fallback only when the left is null. Null-conditional receiver?.member, receiver?.Method(args), and receiver?[index] evaluate the receiver once. A null receiver produces null without evaluating call arguments or an index. The result must be a reference; primitive-valued access and assignment through a null-conditional access are rejected until nullable value types are supported. foreach (T value in collection) captures the collection once and reads each element at its current index. break and continue use ordinary loop rules. Arrays and strings work in both compilers; strings use the language’s current byte-index semantics. The SDK also iterates List<T> through Count() and Get(index). Its count is checked each iteration, so additions can extend the loop and Set changes are observed. No enumerator is created or disposed. Interpolated strings use $"literal {expression}". Literal text accepts the ordinary \\, \", \n, \r, and \t escapes; {{ and }} write braces. Embedded expressions run once in left-to-right order and use the existing string-concatenation conversion for strings, numbers, and booleans. Formatting suffixes such as {value:x} are rejected. Literal UTF-8 bytes are preserved without normalization, and string length and indexing remain byte based. switch (value) { case constant: statements; default: statements; } selects one branch without fallthrough. A branch can use break to leave the switch. switch (value) { case constant => expression, default => expression } yields a value; a bool switch may omit default when it covers both true and false. Cases accept constant numbers, strings, and booleans, and duplicate cases and branches after default are errors. The switch value is evaluated once. continue cannot target an outer loop across a switch; put the continuation in a loop nested inside the selected branch. collection[start..end] creates a new array or string containing positions from start up to but excluding end. Both bounds are required and must be int; the source and bounds are evaluated once, left to right. Bounds outside 0..Length or a reversed range fail at runtime. Arrays copy their element slots once, so changing the source array does not change the slice; referenced objects remain shared. String positions count UTF-8 bytes, matching existing string length and indexing. Slicing may therefore select a partial UTF-8 sequence. Null-conditional slicing is not supported.

Native builtins include System.Console.Write/WriteLine, System.IO.File text/byte reads and writes and existence checks, System.Convert.ToInt32, and System.Runtime.GC collection/accounting. Objects are managed by a conservative non-moving mark/sweep collector using Linux memory mappings or Windows VirtualAlloc/VirtualFree. Windows file paths are converted from Hydrogen UTF-8 strings to Win32 UTF-16. File reads require seekable files.

The SDK additionally supports generics, string exceptions, List<T>, checked unsafe/manual-memory operations, Buffer, and BinaryPrimitives. These additional facilities are not implemented by the native compiler. The SDK interpreter evaluates both sides of && and ||; generated native and C-backed programs short-circuit. Write explicit conditional guards when sharing code with the interpreter.

  • Native compiler: commands, runtime, project binding, self-compilation.
  • HexLab: binary-file inspection with the SDK’s buffer and unsafe APIs.
  • SDK demo: projects, testing, and local package registries.
  • VS Code assets: highlighting, snippets, check/format tasks, and the LSP process launcher.
Terminal window
ctest --test-dir build --output-on-failure
cmake --build build --target hydrogen_bootstrap_proof
cat build/self_hosting/bootstrap-proof.txt

The proof recompiles the native compiler through three generations, runs the same behavioral corpus with each, and requires identical stage 2/3 compiler and representative application artifacts. Retain a verified native seed to rebuild without C++; a source-only checkout still needs a bootstrap route. Native self-hosting does not replace the SDK’s broader language and tooling surface.

See compiler architecture, future work, and the Australis GUI roadmap.