haXe (Haxe)
A high-level, strictly typed, multi-paradigm programming language that compiles to many target platforms — including JavaScript, C++, C#, Java/JVM, Python, PHP, Lua, HashLink, and Neko — from a single, portable source codebase.
Created by Nicolas Cannasse
Haxe (originally styled haXe) is a high-level, strictly typed, multi-paradigm programming language that compiles a single source codebase to a wide range of target platforms — including JavaScript, C++, C#, Java and the JVM, Python, PHP, Lua, the Haxe-specific HashLink and Neko virtual machines, and historically Adobe Flash’s SWF bytecode. Its central idea is target-agnostic application development: the same Haxe code can ship as a web app, a native desktop game, a server-side service, and a mobile binary, with the compiler doing the work of translating idiomatic Haxe into idiomatic code for each underlying platform.
For close to two decades Haxe has been a quietly influential language. It pioneered the “write once, target many” cross-compilation model later popularized by languages like Kotlin Multiplatform and frameworks like React Native, and it remains a production language behind well-known commercial games and creative tools.
History and Origins
Haxe was created by Nicolas Cannasse and first released publicly in 2005. Before Haxe, Cannasse had developed MTASC (the Motion-Twin ActionScript Compiler), an open-source compiler for ActionScript 2 that was significantly faster than Adobe’s own toolchain and that became widely used in the Flash development community. The experience of writing MTASC convinced Cannasse that ActionScript itself was a limitation — what he really wanted was a more rigorous, statically typed language that could target Flash but also other platforms.
The result, originally styled haXe (lowercase ‘h’, uppercase ‘X’), debuted in 2005 with three initial compilation targets: Flash (SWF bytecode), JavaScript, and Neko, a small dynamically typed virtual machine Cannasse designed as a companion runtime. From the outset, Haxe distinguished itself by being a “real” statically typed language — with type inference, generics, algebraic data types via enum, and pattern matching — that nevertheless could be compiled to dynamic targets like JavaScript without dragging a heavy runtime along.
Around 2012, the project rebranded from haXe to the more conventional spelling Haxe, and the language reached its 3.0 milestone in 2013, which consolidated years of language and standard-library evolution. The Haxe Foundation was established a short time later to provide a more durable institutional home for the language and to coordinate its development.
In the 2010s and 2020s, Haxe’s center of gravity shifted increasingly toward game development. Motion Twin’s Dead Cells, released in early access in 2017 and to full launch in 2018, made HashLink — Cannasse’s modern successor to Neko — visible to a much broader audience and became one of Haxe’s most prominent technical showcases.
Design Philosophy
Haxe’s design reflects a handful of consistent commitments:
- One language, many targets. The compiler emits idiomatic code for each backend (JavaScript, C++, JVM bytecode, C#, Python, PHP, Lua, HashLink, Neko, and historically SWF), with platform-specific APIs exposed via conditional compilation rather than abandoning the cross-platform model.
- Strong static typing with strong inference. Most Haxe code can be written with very few explicit type annotations; the compiler infers types aggressively and reports type errors precisely.
- Structural typing and type unification. Haxe supports structural (“duck-typed at compile time”) typing through anonymous structures and
typedefs, alongside nominal classes and interfaces. - Powerful enums and pattern matching. Haxe
enumtypes are full algebraic data types with constructors that can carry payloads;switchis a full structural pattern-matching construct rather than a C-style jump table. - Macros as first-class metaprogramming. Haxe macros run at compile time in the compiler’s own interpreter and can transform the AST, generate code, validate annotations, and embed external data — a feature few mainstream languages match in scope.
- Abstract types. Haxe’s
abstracttypes let library authors define new value-like types with custom operators and implicit conversions without runtime overhead.
Key Features
- Cross-compilation to JavaScript, C++, C#, Java/JVM bytecode, Python, PHP, Lua, HashLink, and Neko, with historical support for Flash/SWF.
- Type inference that allows nearly annotation-free local code while still preserving strict static checking.
- Algebraic data types (
enum) with exhaustive pattern matching. - Structural typing for anonymous objects and
typedefaliases, alongside classical OOP with classes, interfaces, generics, and access modifiers. - Compile-time macros that operate on the typed AST, enabling code generation, DSLs, and static analysis from within ordinary Haxe code.
- Abstract types for zero-overhead value wrappers with operator overloading.
- Conditional compilation via
#if/#else/#enddirectives keyed off compile-time flags and target identifiers. - The
haxelibpackage manager for distributing libraries to the Haxe community. - HashLink (HL), a VM with a JIT and an interpreted bytecode mode, designed specifically to run Haxe code with reportedly strong performance, and Neko, an earlier lightweight dynamic VM still used for some tooling.
A Small Example
A short Haxe program shows the language’s flavor — class-based OOP, type inference, and a clean syntax that reads similarly to TypeScript or Kotlin:
| |
An algebraic enum with pattern matching looks like this:
| |
The same code, compiled with haxe --js out.js, becomes a self-contained JavaScript file; compiled with haxe --cpp out, it becomes a native C++ project; compiled with haxe --hl out.hl, it runs on HashLink.
Evolution
Haxe’s evolution can be roughly divided into three eras:
- Flash-era haXe (2005–2012), when the language was best known as a more rigorous replacement for ActionScript 3 in the Flash ecosystem, but was already cultivating its multi-target ambitions through Neko and JavaScript backends.
- Haxe 3 era (2013–2019), during which the language matured its standard library, added or refined targets such as C++, C#, Java, Python, and PHP, established the Haxe Foundation, and saw the rise of cross-platform games and creative software built in Haxe.
- Haxe 4 era (2019–present), which modernized the syntax (arrow functions,
final, more refined type semantics), introduced the JVM bytecode target as a peer to the Java source target, and shifted the language toward an audience that increasingly compares it to TypeScript and Kotlin rather than to ActionScript.
Throughout these eras, Haxe’s compiler has remained remarkably small and fast for the scope of work it performs, written in OCaml by a comparatively tiny core team relative to the size of the surface area it covers.
Current Relevance
Haxe today is a specialist tool with a loyal user base, particularly strong in independent game development. The combination of Haxe and HashLink underpins commercially successful titles like Dead Cells, and the OpenFL/HaxeFlixel/Kha/Armory ecosystems power a long tail of indie and hobbyist games — including phenomena like Friday Night Funkin’, whose open-source modding scene helped introduce a new generation of programmers to Haxe.
Beyond games, Haxe continues to serve teams that need to share core logic across web, desktop, mobile, and server with strong static guarantees. Its macro system makes it a particularly attractive base for domain-specific languages and code generators, and its ability to emit clean, readable JavaScript keeps it relevant for front-end work where a strongly typed alternative to TypeScript is desired.
The language is no longer growing as quickly as some of its mainstream peers, but it is actively maintained, supported by the Haxe Foundation, and continues to ship regular releases.
Why It Matters
Haxe is one of the earliest and most fully realized examples of a programming language designed from the start as a cross-compiler. Years before “multiplatform” became a marketing term in languages like Kotlin and Dart, Haxe demonstrated that a single statically typed language could generate idiomatic code for radically different runtimes — from a browser’s JavaScript engine to a native C++ binary to a custom VM — while preserving a coherent type system and standard library across them.
For students of language design, Haxe is interesting for blending features that mainstream languages adopted only later: structural typing alongside nominal typing, hygienic compile-time macros, algebraic enums with exhaustive pattern matching, and abstract types with operator overloading. For code archaeologists, it is also a window into the Flash era — a reminder that one of the most ambitious cross-platform languages of the 2000s and 2010s grew directly out of the constraints of a now-retired runtime, and outlived that runtime to find a new life in independent games and creative software.
Timeline
Notable Uses & Legacy
Dead Cells (Motion Twin / Evil Empire)
The acclaimed roguelike action-platformer is written in Haxe and runs on HashLink, the Haxe-specific virtual machine created by Nicolas Cannasse. The game is shipped across PC, consoles, and mobile from a shared Haxe codebase.
Northgard and Evoland (Shiro Games)
Shiro Games, co-founded by Nicolas Cannasse, builds its commercial titles — including Northgard and the Evoland series — in Haxe, using HashLink and the studio's in-house engine on top of the Haxe toolchain.
Papers, Please (Lucas Pope)
Lucas Pope's award-winning dystopian document-checking game was built using Haxe with the OpenFL framework, allowing the same codebase to target multiple desktop platforms.
Prezi
The presentation software company Prezi used Haxe extensively for parts of its codebase that needed to target both Flash (in its earlier years) and JavaScript, and was for a long period one of the largest industrial users of the language.
OpenFL and HaxeFlixel game frameworks
OpenFL reimplements the Flash API on top of Haxe, and HaxeFlixel builds a 2D game engine on top of OpenFL; together they power a large number of indie games, including Friday Night Funkin', which became one of the most-played open-source games of the early 2020s.
Kha and Armory
Kha is a low-level multimedia framework written in Haxe; Armory is a 3D engine integrated with Blender that uses Haxe as its scripting and gameplay language, demonstrating Haxe's use beyond 2D and web contexts.
Language Influence
Influenced By
Influenced
Running Today
Run examples using the official Docker image:
docker pull haxe:latestExample usage:
docker run --rm -v $(pwd):/app -w /app haxe:latest haxe --run Main