Skip to content
Andrew Lind edited this page Jul 8, 2026 · 11 revisions

Hatchet is a transpiler from Haxe 4.x to C++98 — portable source that compiles under Visual C++ 6.0, and therefore targets legacy platforms such as Windows 9x and older Unix toolchains. It is a transpiler, not a compiler: it emits C++ source you then build on the target, and it never produces a custom C++ runtime. Supported Haxe constructs map to an equivalent, hand-writable C++ idiom. Hatchet implements a focused subset of Haxe 4.x; it is not a drop-in for hxcpp.

hxcpp compatibility is compile-time only. A guiding principle of Hatchet is that the Haxe you write always compiles under hxcpp (Haxe's official C++ backend), so the source stays valid, portable Haxe you can keep editing and type-checking with normal Haxe tooling. Hatchet makes no guarantee that the hxcpp build runs or behaves identically — the supported, authoritative runtime is the C++98 that Hatchet emits. The two targets can diverge at runtime (most notably value vs. reference semantics: a Hatchet value class / abstract is a flat value, while under hxcpp the same type may be a heap object). Validate behaviour on the transpiled C++98, never on an hxcpp build.

Motivation

hxcpp (Haxe's official C++ backend) cannot target C++ revisions older than C++11, which has traditionally put Haxe 4.x out of reach for retro and embedded platforms — Windows 98 + VC6, early Linux, and similar. Hatchet bridges that gap: develop in Haxe on a modern machine, transpile to C++98, then copy the generated .h/.cpp to the target and build them with the old toolchain.

Status

Hatchet is a working transpiler with a real lexer, recursive-descent parser, typed AST, semantic model, and C++ code generator. anachrjsonistic — a small, standalone JSON parser — has been implemented in Haxe and transpiled with Hatchet. The generated output has been built with Visual C++ 6.0 and run on Windows 98 — the primary target — closing the loop from Haxe source to a running legacy binary. Hatchet has additionally been validated against a larger, real-world (closed source) C++ game engine.

Hatchet fails loudly rather than guessing — an unresolvable type or an unsupported idiom is a hard error that skips that module and fails the run (see Diagnostics) — and it always generates the prelude, so a standalone project compiles with no boilerplate (see The Prelude).

What's supported

Supported today, end to end:

  • Declarations — classes, interfaces, enums (including parameterized enums and enum abstract), typedefs, the fixed-width UInt8/16/32 shims, extern interop wiring, and automatic forward declarations for mutually-recursive types.
  • Value Types & Abstracts — value classes (@:stackOnly) and abstract Name(U) newtypes with @:op operator overloading and @:to / @:from conversions.
  • Members & Access — access-level mapping, property accessors with real Haxe routing, @:overload, @libexport, @cexport, and abstract classes/methods.
  • Statements & Expressions — control flow, switch with destructuring, containers and their ops, strings, lambdas, module-level functions, exceptions, and the Math / Std / Sys intrinsics.
  • Conditional Compilation#if/#elseif/#else/#end and the __cpp__ / untyped / @:include / @:cppFileCode escape hatches.
  • Types & NullabilityFloat/Single, Haxe division semantics, the full shift set, and Null<T> lowering.
  • Memory Ownership — a whole-program escape/ownership analysis plus the @owned / @sink / @delete overrides.

Two topics get their own pages because they carry deliberate divergences and interop rules:

  • Container SemanticsArray and Map are value types in the generated C++ (Hatchet's largest divergence from Haxe).
  • Metadata and Interop via @proxy — the metadata Hatchet honours, and binding to hand-written native C++.
  • Raw-Pointer Interop — the hxcpp pointer types (cpp.RawPointer, cpp.Star, cpp.ConstStar, cpp.Void), the .raw idioms, and Dynamic / Any as an opaque void*.

Getting started

See Building & Usage for requirements, the build commands, the CLI, and the full flag table. For how Hatchet is structured internally, see Architecture.

Clone this wiki locally