Is Haxe worth learning?

Gordon Potter picture Gordon Potter · Sep 6, 2009 · Viewed 35.6k times · Source

For people out there using Haxe, what makes it useful for you? Reading the website it looks very promising. Does it provide significant portability?

What are some real world and perhaps under appreciated advantages?

What are the pitfalls or gotchas?

Answer

Franco Ponticelli picture Franco Ponticelli · Sep 6, 2009

Is Haxe worth learning?

The short answer is: Absolutely!

For people out there using Haxe, what makes it useful for you?

If you're a web developer, you know you can't stick with a single technology for too long. Sooner or later you'll have to deal with changes in the environment or targets (you develop for .NET but an important customer requires PHP, or maybe that widget should be in Flash not Javascript), and this is the best case scenario. In the worst case you'll have to switch constantly, often multiple times in the same business day.

Those switches can waste a lot of your time because you need to change your programming paradigm too many times and possibly because you will have a lot of overlaps in coding your libraries for specific targets. Haxe tries to ease the pain of transition by having just one source language (the Haxe language) and many outputs (through the Haxe compiler). The language is very friendly and quite easy to learn, no matter your background.

Reading the website it looks very promising. Does it provide significant portability?

The language is the same no matter what platform you deploy to. So you define classes/interfaces/enums/typedefs in the same way for JS, Flash, C++, etc. If those types you define do not depend on a specific platform API, they can be reused from platform to platform with no effort at all. All the platforms also share common APIs like XML access, HTTP connections and reflection. Platforms that have things in common (i.e. Neko and PHP) share the same API for things like file access or web-server development.

What are some real world and perhaps under appreciated advantages?

  • If you are experienced with Flash/Flex you know how the compiler can slow down your work (the only advantage is being able to take a coffee break while waiting ;) ). The Haxe compiler is many times faster, so fast that most of the time you don't even notice it working.
  • The bytecode produced is much faster than the equivalent produced by Adobe tools.
  • Also in the Flash realm, Haxe can "inline" functions or access the Memory features that are only available elsewhere by using Alchemy.
  • In case you need it, you can also decide what version of Flash to target, from 6 to 10; the API has changed a lot but the Haxe language is exactly the same.

Talking about the server side, we all know how ubiquitous PHP is. You can develop an application with Haxe targeting it and scale to Neko or even C++ if your web application grows.

What are the pitfalls or gotchas?

Here's a list of common misconceptions:

  • Haxe is young and immature Not really, Haxe is almost 4 years old now, has seen 25 formal releases (not builds) + 13 alphas and betas, it is updated constantly and has a very dedicated community. It is used professionally by a lot of people in several development areas; take a look at the mailing list archive to find how people use Haxe.

  • Haxe is complicated Because the main target of Haxe is without any question AS3, people expect that it must have wizards or a GUI. As stated Haxe is a language and a compiler which makes it suitable for programmers but not very good for designers.

  • There aren't any IDEs The true part of this is that IDE could be improved in a lot of aspects to better integrate with Haxe but there are already a lot of valid options.

  • The only book published is already outdated There is some truth here too, unfortunately the book was published just a few months before a major release occurred (from V1 to V2). That major release didn't change much, but it did add a few incompatibilities. The book still remains a valid resource (I'm not just saying that because I wrote it ;) )