Enabling Haxe to target a new platform: Intro

There are many possible reasons to enable Haxe to target a new platform. Currently, supported platforms are Neko, PHP, Javascript, Flash6/7/8, Flash9 and Actionscript 3.0. In origin, the only available server platform was Neko, a powerful but not easy to deploy platform. During a long time many people asked for PHP support as it's the easiest and cheaper platform to run web applications. Thanks to Franco Ponticelli's work, Haxe2 lets us deploy our Haxe applications in PHP servers.

"Deploy everywhere" is an interesant idea but there are some other reasons to make Haxe support a new target:

  • Use of developer tools of the new language: testing, profiling, ...
  • Reuse of existing libraries
  • Enable Haxe to work in a different environment. Haxe is a web language, but being able to create real-time applications would be nice.


A compiler essentialy is an application that translates source code from one "origin" language to another "destination" language. Haxe compiler can take this piece of code and transform it into a different language.

var x = 1; 
var y = x + arr[0];

With an hypothetical Haxe -> Python compiler we'll obtain this compiled code:

x = 1
y = x + arr[0]
haxe_Log_trace y

But not all plataforms execute this kind of human-readable text script. Only interpreters do. For instance, Mono/.NET use an assembler-like language (CLI), and the compilation of the same code would produce this output :

ldc.i4 1
stloc x

ldloc x
ldloc arr
ldc.i4 0
callvirt instance void class [mscorlib]System.Collections.ArrayList::get_Item(int32)
unbox.any [mscorlib]System.Int32
stloc y

ldloc y
box [mscorlib]System.Int32

More complicated, isn't it? Well, not all platforms are equally difficult to implement. Nicolas Cannasse had much more problems to implement flash9 target than with flash8 because of its type system. Adding Java Bytecode as a target can be a painful job!

version #4246, modified 2008-09-16 13:17:03 by mserranom