Haxe consists of a high-level, open source programming language and a compiler. It allows compilation of programs, written using an ECMAScript-oriented syntax, to multiple target languages. Employing proper abstraction, it is possible to maintain a single code-base which compiles to multiple targets.
Haxe is strongly typed, but the typing system can be subverted where required. Utilizing type information, the Haxe type system can detect errors at compile-time which would only be noticeable at run-time in the target language. Furthermore, type information can be used by the compiler to generate optimized and robust code.
Currently, there are nine supported target languages which allow for different use-cases:
|Name||Output type||Main usages|
|Neko||Bytecode||Desktop, Server, CLI|
|HashLink||Bytecode||Desktop, Mobile, Game consoles|
|C++||Sourcecode||Desktop, Mobile, Server, Game consoles|
|Java||Sourcecode||Desktop, Mobile, Server|
|JVM||Bytecode||Desktop, Mobile, Server|
|C#||Sourcecode||Desktop, Mobile, Server|
The remainder of this section gives a brief overview of what a Haxe program looks like and how Haxe has evolved since its inception in 2005.
Types introduces the seven different kinds of types in Haxe and how they interact with each other. The discussion of types is continued in Type System, where features like unification, type parameters and type inference are explained.
Class Fields is all about the structure of Haxe classes and, among other topics, deals with properties, inline fields and generic functions.
In Expressions we see how to actually get programs to do something by using expressions.
Language Features concludes the Haxe language reference by describing some features in detail such as pattern matching, string interpolation and dead code elimination.
We continue with the Haxe compiler reference, which first handles the basics in Compiler Usage before getting into the advanced features in Compiler Features. Finally, we will venture into the exciting land of Haxe macros in Macros to see how some common tasks can be greatly simplified.
Haxe abstracts away many target differences, but sometimes it is important to interact with a target directly, which is the subject of Target Details.