-
Notifications
You must be signed in to change notification settings - Fork 0
Home
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 /
abstractis 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.
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.
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).
Supported today, end to end:
-
Declarations — classes, interfaces, enums (including parameterized enums and
enum abstract), typedefs, the fixed-widthUInt8/16/32shims,externinterop wiring, and automatic forward declarations for mutually-recursive types. -
Value Types & Abstracts — value classes (
@:stackOnly) andabstract Name(U)newtypes with@:opoperator overloading and@:to/@:fromconversions. -
Members & Access — access-level mapping, property accessors with real
Haxe routing,
@:overload,@libexport,@cexport, and abstract classes/methods. -
Statements & Expressions — control flow,
switchwith destructuring, containers and their ops, strings, lambdas, module-level functions, exceptions, and theMath/Std/Sysintrinsics. -
Conditional Compilation —
#if/#elseif/#else/#endand the__cpp__/untyped/@:include/@:cppFileCodeescape hatches. -
Types & Nullability —
Float/Single, Haxe division semantics, the full shift set, andNull<T>lowering. -
Memory Ownership — a whole-program escape/ownership analysis plus the
@owned/@sink/@deleteoverrides.
Two topics get their own pages because they carry deliberate divergences and interop rules:
-
Container Semantics —
ArrayandMapare 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.rawidioms, andDynamic/Anyas an opaquevoid*.
See Building & Usage for requirements, the build commands, the CLI, and the full flag table. For how Hatchet is structured internally, see Architecture.
Hatchet is licensed under the MIT License — see LICENSE. (c) 2026 Andrew Grant Lind
Getting Started
Language Support
- Declarations
- Value Types & Abstracts
- Members & Access
- Statements & Expressions
- Types & Nullability
- Conditional Compilation
- Memory Ownership
Semantics & Interop
Internals