HaXe – 1 Language, 9 Targets

As more and more technologies develop, new languages pop up. A new language means a lot of time spent researching functionality, and getting acquainted to various quirks. Each language comes with it’s own way of doing things, and it’s own little tricks. Wouldn’t life be so much easier if you just had to learn one language that would take care of translation for you? Well, there’s hope. HaXe (pronounced hex in English: /heks/) offers the glorious solution of one language which compiles to multiple targets. It’s also open-source.  To quote their introduction, “The idea behind Haxe is to let the developer choose the best platform for a given job. In general, this is not easy to do, because every new platform comes with its own programming language.” Current targets of HaXe are Flash 6-8, Flash 9-11, Neko, PHP, AS3, JavaScript, C++, Java, and C#. One can code for all these environments with little modification when going from client-side web apps, server-side web apps, stand-alone apps, or native-code apps for mobile OS platforms like iOS, Android, or webOS.

Advantages of targeting multiple platforms include the ability to pass objects between different platforms with ease, a single syntax and features (no more need to switch between the ‘java’ or ‘c++’ mindset.) HaXe’s compiler comes with conditional compilation which allows code to be tailored for a specific platform, or multiple. It’s all up to the developer.

Some of the language features of HaXe (meaning this applies for all supported targets!) include:
– Classical Object Oriented class + interface model (similar to Java)
– Strict typing with dynamic support.
– Packages and modules
– Generic types
– Local function declarations, including this capturing
 Powerful enums (with constructor parameters and pattern matching, support for recursion)
 - Exceptions
 - Iterators
 - … and more!

I can think of a million places this is useful, but probably (for me) the most prominent is how hacky JavaScript is normally, and how much cleaner this makes it. HaXe is definitely a huge advantage to know, and for anyone developing cross-platforms, it seems like an obvious boon.

See the official site for more.