Converting programming languages to and from Haxe code

This is a bit of a “public service announcement” in case anybody finds it to be useful.

I recently found “Refactor” in Haxelib which will convert many different languages to Haxe code or externs: https://lib.haxe.org/p/refactor/
It has scripts for making Haxe from Java, ActionScript 2, PHP, C#, C++, TypeScript, or JavaScript and can also convert Haxe to C++, C#, or Typescript.

In the past I have also found these other libraries for converting Actionscript 3:

And finally there is this project for converting Go to Haxe:

4 Likes

There’s also DTS2HX: Use TypeScript definitions with Haxe: dts2hx is ready to use! - #14 by Zhan

If anybody has anything else to add to this thread, please do!

2 Likes

Thanks for including go2hx! I would like to note that conversion tools can be quite a bit different then compilers, conversion tools in the case of “Refactor” uses a set of rules to convert to X language into Haxe, it can be used for porting a codebase into Haxe, however manual work will still need to be done as it won’t handle (or only partially) the stdlib, type information, and won’t have the rigorous testing of a compiler.

It’s of course not black and white and in the case of dts2hx in a way it’s the best of both worlds, it operates as a compiler and uses AST type information, but it doesn’t need the stringency of a compiler because edge cases that it can’t handle, it can fall back to Dynamic.

go2hx is a compiler with the goal is to get any valid go code within a subset to be compiled into Haxe including the stdlibs/libs imported without any manual work needed.

2 Likes