Friday, June 7, 2013

The Haxe Programming Language

This is a language that has seemed to slip by under the radar for the most part. Haxe, commonly pronounced "hex" or "hacks" is a language that targets many virtual machines, instead of the more common virtual machine that targets many languages.
It has a reasonable standard library that feels designed, much like Python's. The syntax is Go like, with identifiers following names:
class WebFetch 
{
static function main()
{
var output = haxe.Http.requestUrl("http://www.google.com/");
Sys.print(output);
}
}
When built, this program is a ~68Kb JAR file when targeting Java or a 550Kb ELF when generating C++.
Compilation is straightforward, consisting of an internal build system that resolves libraries well, and a global repository that you can pull new packages from.
One of the biggest benefits of this language is its ability to compile and run on so many platforms; it easily handles:
  • Android
  • Flash
  • Linux
  • Mac
  • Windows
  • HTML + JS
  • PHP
  • Java (in Beta)

Example Uses

  • You're a web-developer and have some business code that needs to target language of the day. Haxe can compile to language of the day without the need to translate.
  • You want to code a cross-platform game to reach as broad of an audience as possible without re-writing lots of code.
  • You want to develop a client for an API you publish so developers will actually use it without learning all of the languages it is going to be used in or maintaining the libraries.
  • You want to develop an app that is future proof, but don't mind it being a little ugly.

Pitfalls

  • There is no standardized UI system.
  • The coding conventions are a strange to begin with.
  • There are some obvious deficiencies in the standard library (no string compare)
  • Code is slightly larger than it would be natively.

Conclusion

Overall, Haxe is a good language that I see myself using in the long run because it is so future-proof and well designed. Plus, the ability to do things easily cannot be underestimated. The example above would have taken over 100 lines of Java and about the same in C++, instead it took eight and thirty seconds to put together after knowing the language less than twenty-four hours.

No comments:

Post a Comment