HTML5 based game - Haxe pros?

If we are talking about doing a game targeting the web. What are the pros and cons of using Haxe for this task in comparison with doing it in pure JavaScript or TypeScript? What are the best Haxe-based 2d game engines that is capable of targeting the web in terms of game execution speed and the size of generated JavaScript code?

Comparing to JavaScript, a static type system (but with opt-in dynamic typing and type inference) and compile-time error checking are big wins. In my experience they prevent a ton of errors and make iteration faster.

Andy Li had a blog post comparing TypeScript to Haxe which you might find helpful. There are features in Haxe which I really appreciate (powerful macro system, abstract types) which are not present in TypeScript. If your game may target anything other than the web in the future, Haxe compiles to native code on a variety of other platforms, so you won’t be limited to just JS.

A simultaneous pro and con is the smaller number of libraries compared to the JS ecosystem; the number is smaller, but the signal-to-noise ratio for Haxe is much better. I haven’t found this to be a problem.

I won’t touch “best” 2D game engine since I’m very biased :slight_smile: but OpenFL, Kha, HaxeFlixel, HaxePunk, and Heaps are all excellent options.

1 Like

I’m creating html5 games for few years now, mostly for mobile web. It’s the reason I start using Haxe too :slight_smile: I started with using Flambe (pure Haxe) but we recently stopped using it. We switched to pixi.js. This is a JavaScript library and we use the haxe-pixi externs to interface with it, this works seamless.
We also use howler.js for sound. This is also pure js lib and we use the howlerjs externs, which are also great.
The reason we switched is because Flambe isn’t maintained anymore and the pixi.js rendering is the fastest I’ve seen for 2d on web and has regular updates.

The downside is that you have to include the full pixi.js lib, where (if you go the js way you could shave off more because with certain workflow you can bundle only is used). For me these few bytes aren’t worth the trouble, and I think games are small enough for what you get. We minify the games with closure library. The upside is that you can use Haxe; The language is great, its easy to build a workflow with it and some macros help making development very nice/fun. An average game, bundled and minified in our current setup is ~500 - 700kb. Note that js files should be served gzipped, so in practise users download ~150kb.

I’ve also worked on few Heaps games for fun, I really think it can be a nice alternative at some point, since it’s pure Haxe.

2 Likes