Haxe for Flash Development

Published March 10, 2010
Advertisement
(from the Flash Gaming Summit)

Haxe for Flash Development

Haxe is a compiler

MXMLC - translates as file into a swf

Why make an entirely new language after making MTASC, as AS3 is well established?

Couldn't really modify AS3, as it'd break backwards compatibility, so you might as well go all the way.

DRY - Don't Repeat Yourself.

var x:int = 1 + 3 // why bother saying int if the values clearly establish that?

In Haxe, type is inferred by the values stored.

AS has an Array, Dictionary and Vector class. They're fast but are not customizable.

Haxe has generics, ala C++. When instantiating an array, for example, you do not have to cast the type.

Haxe has enums in addition to classes. Enums are frightfully handy. Thus-far, it strikes me that Haxe is intended to move some of the better C++ bits to AS3.

Haxe has array iterators, which makes array looping simpler. It's different from foreach, as iterators are available for other kinds of collections.

Haxe also supports inlining and other performance-improving features. The inline keyword works just like its counterpart in C++. Apply it judiciously, as you can possibly make your whole app into one giant function.

Haxe supports "Alchemy Global Memory", which is a secret set of Flash memory opcodes for their C++ translator gizmo. It's not documented, but it was discovered by decompiling some other code to see what was going on. It's a bit difficult to use, as it's just a pointer to one bigass block of global memory. He showed off its use by porting the "Quake Fast Inverse Square Root" hack to Flash, which is a way faster way to determine distance than Math.sqrt()

Bottom line, the flash.memory based invSqrt is about eight times as fast as the one in the Flash Math class.

Haxe is not all about Flash. It can target SWF9 and SWF10 (i.e. both VM's) as well as SWF 6-8. It can also target &#106avascript, generating a single .js file. It can target PHP. It can target NekoVM, which is a fast server-side technology.<div> </div>
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement