Skip to content

haXe, The Javascript X-Compiler (it’s not just for Flash!)

April 22, 2010
It’s well publicised that haXe supports many platforms; Flash, C++, Neko, PHP and Javascript, yet on asking on the node.js irc channel why few people use haXe, an answer came back that basically it was too associated with Flash. On reading the haXe mailing list that is certainly the impression one gets.
However, tucked into the list of compiler output targets is Javascript, which I believe will provide haXe, the language, the recognition is deserves. This is, in reality, based on the resurgence of Javascript on the server with node.js, and the massive boost on the client with html5 – and generally strong progress in performance with new Javascript engines (v8). Javascript as the ‘assembly language of the web’, IMO, needs a compiler, and haXe seems to me to be extremely well positioned to be the defacto compiler.

The Language.

I won’t say a lot about the language itself, as you need to try it, but it’s a great fusion of strong/weak typing, oop/functional styles, and has a damn fast compiler, try it out you won’t be disappointed! Some bullet points:
  • Javascript like syntax
  • Classes and typedefs (multiple defs in one file)
  • Closures
  • Generics
  • Supercharged enums (OCaml like discriminated unions)
  • Lambda library
  • Full reflection, RTTI
  • Easy definition of type signatures for external libraries
Here’s the link to a full description of the language

The Server, Node.js

Node.js ( is a server async platform which is scripted in Javascript using the Google V8 engine. I don’t mind writing Javascript, but like many others prefer the helping hand of a compiler and strong typing when I have more than a few functions. So if I could write to the Node.js API taking advantage of the haXe language, this would be a big win?
Well you can and it is! Try my simple haXe wrappers for Node.js which you can find here. By adding this project to the haXe compiler classpath you can take advantage of the latest node.js API.

The Client.

It’s time to revaluate haXe on the client, it’s not just for Flash! The Javascript compiler target was originally designed for client side, and with html5, and other major library works like Google’s Closure or YUI3 etc, haXe can play a part in making the management and deployment of large apps much easier by providing an end to end solution.
Although unfinished, my hxClosure project is an example, of using haXe wrappers to make the Google Closure library accessible to haXe. Standard desktop libraries can also be accessed, e.g. Gtk. haXe can also target the iphone via it’s C++ target (I guess this is now possibly a problem due to the licensing restrictions).

haXe, End to End

The haXe Javascript X compiler provides one great type checked language for all tiers of the web, allowing reuse of data structures and code in the server and client – no matter if the client is HTML, Flash or Gtk.

From → haxe, javascript, node.js

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: