There don’t seem to be any substantial articles about the downside of using Haxe. That should have been my first warning sign. If, after several years, a language doesn’t have enough people talking about it to have some detractors, there’s got to be something wrong with it. I’m not going to go into the Haxe benefits because there are plenty of pro-Haxe articles out there. I won’t go as far as saying Haxe sucks – there are plenty of really cool ideas in it – but in my opinion Haxe is, and will always be, a hobby language.

This is what I wish I had known before I invested several days in an eventually aborted attempt to port from AS3 to Haxe.

First, it is not being designed by a group of industry veterans, but primarily by one guy with veto power. The creator is undoubtedly a genius, but very young. Haxe is also young – it has lofty goals, but doesn’t seem to know what it wants to be. The design pushes (makes mandatory in many cases) certain design patterns, as if it wants to enforce perfect programming principles – yet it is based on Actionscript, one of the worst languages I’ve ever used. It can build for zillions of platforms, which was the big attraction for me, but in a basic build, I ran into serious compiler errors – incorrect errors being generated. This is a big problem – sure Adobe’s compiler has plenty of bugs, but at least there are zillions of people using it, so you can be sure there are workarounds figured out for just about every issue. If you have the time to report issues I’m sure the Haxe developers would be much more responsive than Adobe, but I just don’t have time for that – hobbyists do. Finally, there just isn’t much 3rd party documentation on using Haxe. Documentation and examples are more scarce than I imagined, most are written by the developers themselves, and many are out of date. Several examples on the Haxe website don’t even build with the latest version.

I’m not going to bother trying to convince anyone to change Haxe, because I just don’t think you can get there from here. But starting from scratch with a language, I think you should pick a direction, either:

  • a strict, well designed language, starting from scratch with design coming from several brains, or
  • a flexible, easy to use language that extends and improves on Actionscript

You can’t have both.

Haxe Annoyances

These aren’t deal breakers, but just a few of the things I found annoying about the language. The design of Haxe seems to be focused on preventing a few specific bad programming habits, at the expense of code readability & simplicity. I prefer an approach that prioritizes code readability & simplicity, and promotes the use of elegant, clean coding patterns. Converting AS3 to Haxe was turning into a monumental task because of several odd decisions in Haxe:

No auto-cast to Bool


if(!sprite) sprite = new Sprite();
if(str) trace(str);

This is easy to understand, why require the “==null” check?

No square braces to access object properties


obj[str]

is much more straightforward than


Reflect.field(obj, str)

Yes, it’s not the optimal way to access properties, but do we need to make the code uglier to make that point? I never accidentally mistake an object for an array.

Lack of varargs

Forcing args to be manually placed into a dynamic array is pointless and ugly.

No comma separated property declarations

I like organizing properties by grouping horizontally:


public var posX:Float, posY:Float, rotation:Float;

Haxe forces a vertical style preference here. I see no reason to force this on people, and it was such a big pile of work that I instead ended up writing a nightmare of a regex to do it manually.

Traditional for(;;) loops are an elegant, simple pattern; why break that?

An iterator-based syntax can be used with while(item in iter), there’s no reason to break an existing standard. Arbitrary changes like this make people like me question the sense of moving to Haxe. The traditional for() pattern is elegant for custom loops, where you would be building a fancy custom iterator that would only be used in one place. One example is a custom search of a linked list, which starts at a custom element.

Example

old, clean AS3 code:


if(counters) counters[name]++;

new, ugly Haxe code:


if(counters!=null) counters.set( name, counters.get(name)+1 );

The End

There are doubtless many more examples, but I’m done. Anyone know of an easy macro preprocessor for Actionscript?