So I swore I’d never touch Haxe ever on twitter recently. At least for a year or so. Why? Well, I’m too busy; Haxe isn’t quite mature enough for my tastes; support forums are kinda slim pickings and it’s hard to Google solutions to common problems. Mostly, though? I’m just scared of new things. I knew I should probably give it a try, and just decided not to.
A Wild Update Appears!
Well, early this morning a new version of FlashDevelop was released, with enhanced support for Haxe NME. I found myself in a fell mood, locked myself in with a livestream, and gave myself 1 hour to learn Haxe and make a game!
First up, some Q&A. These are questions I had that I didn’t really know the answers to until I dug into it, so I’ll share what I found with you:
What is HAXE?
It’s a free programming language whose syntax is based on ECMAScript (similar to UnityScript, ActionScript 3, and Dart syntax). The project grew out of AS3, so it bears the most similarity to it. Here’s the official website and the wikipedia entry. I don’t recommend you download Haxe just yet, read on…
How do you pronounce it?
Wikipedia says it’s officially “hex,” but some jerks call it “hacks” and it’s starting to stick. I’m going to call it “hex” from now on!
What is NME?
It’s a free library collection for Haxe that closely emulates the Flash libraries we know and love – the DisplayList, Sprites, Bitmaps, Textfields, Points, Events… All those lovely things. The combination of Haxe and NME creates the most comfortable transitional environment for AS3 developers, though there are some big changes. See the official website here. The download for NME includes Haxe itself, along with a bunch of other requisite files, so I recommend grabbing this!
Why use Haxe NME?
The two biggest reasons to use Haxe NME are SPEED and OUTPUT TARGETS.
SPEED: Haxe NME consistently outperforms every single AS3 metric I’ve seen. Name a test. Any test. Haxe NME will outperform it. Adobe’s .SWF compilations, AIR compilations, and even AIR’s swf-to-native-bytecode iOS/android compilations introduced in AIR 3.1 can’t touch this magic. From iterating through arrays to displaying particle effects, Haxe is simply a better compiler.
Another good reason to use it? It’s a more advanced/mature language than AS3, so some common annoyances have been addressed and many aspects of development are much easier.
What’s different between AS3 and Haxe syntax?
Take a look at this article right here, it’s pretty much my bible as an ActionScript developer. Check out the awesome upgrade to FOR loops in there. We even have (optional) automatic type inference in there, while maintaining strict typing! Less keystrokes with all the debugging magic. You should also read this whole blog, it’s great.
So what did I make?
I opened up FlashDevelop, and with no experience (and armed with only the basic knowledge above) I started hacking away at a Haxe project. LiveStream captured my hour-long effort, but an hour of me getting frustrated and looking at docs doesn’t make for good TV, so I didn’t paste it to youtube. If you really badly want to check it out, look in my Twitch.TV video archive. :P
With a lot of help from the studio audience (Pekuja in particular!), I managed to get a little game together: FACE CHASER! Play it now!
- Your face is being chased down by an ANGRIER face!
- The angry face has 3 hit points, which it loses as it bumps into the edge of your browser. You’ve got to play chicken with it!
- When angry face dies, a FASTER angry face appears!
- If angry face touches you, YOU DIE Spams the background!
You can check out a .ZIP of my complete FlashDevelop package here, if you want it. I wouldn’t. :3
So how was Haxe NME?
Intriguing. It’ll take a lot of practice to get coding in it quickly, and I’ll need to convert a lot of my library helper functions, but it’s overall pretty darn good.
I wouldn’t use Haxe NME for a commercially sensitive project right now. If something goes wrong, or you need a fancy binary plugin library or something, you might be out of luck. But if you keep things simple…
Well, let’s just say I’m going to try to use Haxe NME for all my future game jams. :) Maybe slowly over time I’ll get up the courage to use it for everything!