Select Page

Haxe_logo.svgHaxe is a lesser known but quickly ascending language + toolkit. Haxe is used to write games, apps, and web apps on multiple platforms. Haxe itself is not natively supported, but rather it compiles to other languages including ActionScript, Java, C++, C#, Python, PHP, Node.js, and plain JavaScript.  The ability to target multiple platforms has helped Haxe earn its primary identity as a game development tool. As such, you can easily find Haxe for game development resources. I am going to focus this blog series on Haxe and JavaScript for web applications.

Later on, I will compare Haxe and CoffeeScript side by side for perspective. But for now, it is interesting to note that CoffeeScript takes a nearly opposite approach to Haxe:

  • While CoffeeScript is dynamically typed and expressive, Haxe is statically typed and verbose.
  • While CoffeeScript essentially IS JavaScript and translates 1:1, Haxe is a higher level language with its own constructs.
  • While CoffeeScript integrates seamlessly with JavaScript libraries, Haxe must abstract them into extern classes that it can understand.
  • While CoffeeScript gives you easy access to the DOM and tools like JQuery, working with Haxe feels a bit more removed from the DOM and frustrate when you want to do something you normally pull off in JavaScript without a thought. Though in the end, Haxe’s tooling is powerful and nothing is out of reach.

So when would you want to use Haxe in web app development? Certainly not for light scripting. The strengths of Haxe become most apparent in large javascript applications. Compiling the statically typed language means that many bugs are caught at compile time rather than runtime. Haxe also introduces some modern language features that make it feel like you are using a superior version of JavaScript. Things like package management, class inheritance, interfaces, public/private, and complex data types are neat and tidy in Haxe.

Haxe can also be used to write php and nodejs giving a developer the ability to code the whole stack in one language. But that’s for a different series.

In this series, we’ll cover the very basics of Haxe and see how it compiles to JavaScript.

Part 2: Getting Started