Haxe Features
This is a non-exhaustive list of haXe features - use it as a quick overview of the kind of things you can do with haXe.
Supported Platforms
On the client-side, many platforms are supported.
- Can compile to JavaScript by generating a single
.jsfile- interactive debugging directly in Haxe sources with JS Source-Mapping (
-debugwith Haxe 2.09+) - highly reduce the script output size with
--dead-code-elimination
- interactive debugging directly in Haxe sources with JS Source-Mapping (
- Can compile to C++ source code which can then be compiled to native binaries
- allows targeting iOS, Android, and other mobile targets
- see NME for a good example
- Can compile to Flash by generating a
.swffile - haXe compiled swf files usually run faster than AS3 due to advanced optimizations- use interactive debugger if your IDE supports it with
-debug -D fdb - can compile to SWC and import SWF libraries (produced by IDE or 3rd party libraries)
- can compile to AS3 source code
- use interactive debugger if your IDE supports it with
On the server-side, you can use Haxe as well, enabling code-sharing and better team communication :
- Can compile to NodeJS or other server-side JS technologies
- Can compile to PHP 5, so you can deploy it easily everywhere
- Can compile to NekoVM by generating a single
.nbytecode file- a small embedable VM with high performances and small footprint (more)
- can be run from the commandline or in Apache Web server (with mod_neko or mod_tora)
- Includes an advanced ORM called SPOD Macros
Language Features
Here's a list of some of the Haxe language features. All these features are tested to run the same on all supported platforms thanks to a lot of unit tests :
- Classic Object-Oriented
class+interfacemodel (similar to Java) (more) - Strictly typed but with Dynamic support
- Packages and modules
- Generics (type parameters) with one or several constraints, but not variance
- Advanced Type Inference for all variables including methods arguments and return types (except member variables)
- Anonymous Structures with structural subtyping
- Strictly typed function types, functions closures and partial applications
- Polymorphic Methods (per-method type parameters), with constraints
- Optional and constant default value function arguments
- Explicit Inline methods and constant inlined variables
- Local function declarations with
thiscapturing - Automatic closure creation
- Powerful Enums (with constructor parameters and pattern matching)
- No statements : only expressions
- Exceptions (try/catch)
- Metadata
- Partial function call with
callback - Getter/Setter and more with Properties
- Method injection with "using" mixin
- Conditional Compilation
- Iterators
- Syntax shortcuts using Macros.
You can learn more about the different language features by reading the Haxe Language Reference
Standard Library
Haxe comes with batteries included : the crossplatform standard library is quite complete and lets you do many things, such as :
- Basic Types : Int, Float, Bool, Void
- Std for common conversions
- String handling with String class, StringTools, StringBuf and UTF8 classes
- Array, List, Hash and IntHash containers
- Date and DateTools
- Math
- Regular expressions
- Functional Lambda api for Iterable
- Reflection API (Reflect and Type classes)
- Serialization (Serializer and Unserializer) with open format
- Using Xml parser with Fast access and validation
- Runtime Metadata access
- External File Resources
- Unit Testing support
- Http requests/responses
- Int32 and Int64 manipulations
- Bytes binary buffers
- Input and Output abstract IO streams
- Database SPOD ORM with compile-time type checking and SQL generation
- Cross-platform communications with Haxe Remoting Tutorials
- Web Dispatcher for URLs
- .... and much more
Tools and Libraries
Looking for a given library or want to share one with the community? Look at haxelib, the Haxe library packager systemIf you want to customize the way Haxe works, you can use some of these features :
- compiler-based completion support for easier IDE integration
- Macros for language customization and compile-time code generation
- customizable JS output
- XML output for documentation
- trace and file position support
Here are some third party tools or libraries that we recommend using with Haxe :
- haxelib, Haxe library packager
- JQuery and SWFObject wrappers (Javascript target only)
- FlashDevelop IDE (Windows)
- SublimeText Bundle (OSX)
- File Formats library (ABC,AMF,BMP,FLV,GZ,JPG,MP3,PBJ,PDF,PNG,SWF,TAR,ZIP...) support
- NME and Jeash for games
- HxSL - Haxe Shader Language for 3D shaders