Go2hx Work in Progress

It’s been about 8 months since the initial post, so a progress update is due!

Quick recap of project:

go2hx is a golang to Haxe source-to-source compiler (like Haxe its self) written in Haxe with the main objective to compile as many golang libraries into Haxe as possible for use by Haxe developers.

The reason for this objective is because Haxe lacks a large collection of libraries to be able to use across its many targets portably. Requiring an unfortanate choice of library access vs portability.

Progress:

  • The compiler has become quite a bit more sophisticated ditching a lot of the macro exprs that would work as a poor filler for not knowing type info. Now the compiler directly gets the golang’s ast type info and uses it for type analysis to generate much more proper idiomatic code.

  • Entire tinygo test suite passing except for tests that use time/runtime standard libraries.

  • The go2hx reflection standard library is able to handle almost all runtime inspection.

  • Basic types have greatly improved from go’s slices/arrays/maps/pointers and numbers.

  • A decent portion of go2hx’s go language generation is spec compliant, and more tests coming to increase it.

  • Can now install go2hx with Haxelib via haxelib git go2hx https://github.com/go2hx/go2hx

  • Created some github wiki articles example

Current status:

  • 1000 tests, test suite is being setup to run for github actions (hoping to multi-thread but might not be feasible at the moment).

  • Working towards compiling simple libraries and building up a list of supported ones to increase adoption of the compiler before more spec compliance is met.

  • More work on writing parts of go’s standard library to pass tests is being done.

Interesting showcase parts:

Modified the haxe-test-adapter to be able to set the line number of tests and offset to match an array entry.

Built a simple go2hx REPL that takes golang code as input and outputs Haxe code and runs it.

ZTic1gqESX

Any feedback is extremely appreciated, you can write here and/or create an issue on the repo.

I hope the REPL gives a nice introduction to the compiler and allows some early on experimentation.

Thanks for taking the time to read, the generous kind words have really helped keep the drive strong to finish this project and bring it to life, I look forward to sharing many more posts in the future (in smaller time intervals then the current precedent!)

19 Likes