What's New in Haxe 3.2.0

by Skial Bainn published on

The Haxe Foundation officially released Haxe 3.2.0 on Tuesday 12th May 2015. To read about all the new features, fixes and breaking changes checkout the Haxe 3.2.0-rc2 and Haxe 3.2.0 release details.

しょーへー90.9 has also written New features of Haxe 3.2.0 [jp], so obviously a lot of the same points are covered.

Python Target

The newest addition to the list of Haxe targets is the Python target. The compiler team still class it as a beta target, so if you run into any problems file an issue.

Lets see a rather trivial example.

Compiled with haxe -python Main.py -main Main will generate the following python.

Rest, EitherType, @:selfCall and @:callable

To help improve the accuracy of external type definitions, the compiler team have added two new types, haxe.extern.Rest and haxe.extern.EitherType, also two new compiler metadata, @:selfCall and @:callable.

Note the extern part of the packages, these two types are only ever expected to be used with extern types.


Taking the extern file python.lib.os.Path as an example, its method join looks like the following.

public static function join(path:String, paths:Rest<String>):String;

This allows you pass in an optional amount of arguments of type String.


Lets take js.html.Blob as an example, its constructor, on line 11, looks like the following.

This allows you to pass in an array containing any object that is either a String, ArrayBufferView, ArrayBuffer or Blob type.


The @:selfCall compiler metadata gives you the ability to tag an extern class constructor and method which tells the compiler to translate it into an object call. The following example should help clear up any confusion.

Notice how the methods of extern class A and extern class B are generated differently.


The @:callable compiler metadata allows an abstract type to be called, which will forward that call to its underlying type. If you try to compile this without the @:callable metadata you will get the following error message Function<Int -> Int> cannot be called.

New HTML JavaScript Externs

The JavaScript target has had its HTML extern types updated to take advantage the latest features of Haxe 3.2.0 using a brand new externs types generator created by Bruno Garcia. This is where some of the breaking changes come from.

Typed Arrays

Haxe 3.2.0 adds support for cross-platform typed arrays, which are not to be mistaken for JavaScripts typed arrays. However, Haxe's typed arrays are inspired by JavaScripts typed arrays. I'm making an assumption that any JavaScript typed array article, tutorial or example should translate with minimal changes.


For those of us who use macros, Compiler.addGlobalMetadata allows you to attach metadata to any type or method that hasn't been processed by the compiler. This makes macros even more powerful.

NodeJS support

The Haxe Foundation have a complete set of extern type definitions covering NodeJS 0.12. You get automatic insertion of require statements, optionally typed event listeners and a clean output. To grab a copy just run haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs.git from the command line.

New API Site & Template

The Haxe API site has been updated with an improved design and functionality which is an enhanced version of the Flambe API site and template. You can get the latest code for Dox, the official Haxe API generator, from GitHub.

haxe api
Haxe 3.2.0 API Documentation design update.

HaxeLib Mercurial Support

HaxeLib has recently added mercurial support to its GitHub repository. Its recommended to wait for the haxelib client to be updated instead of installing via git. The hard work of adding mercurial to HaxeLib was contributed by Alex Koz.