The most fun thing about programming in Haxe is just messing with its power. Its compiler is fast, there’s support for some sweet macros, there’s compile-time types that dissolve at runtime, there’s Iterators and Enums, there’s inlining, there’s metadata… and let’s not forget that this language compiles to multiple targets, and does a damn good job at it!
Of course, you shouldn’t use these features for their own sake; you should only consider them when you have some problem that they solve. For instance, if you’re manipulating vertices on a 3D mesh, you might feel compelled to throw some helper functions into your Vertex class, but for the Flash target, this increases the memory footprint of a Vertex instance. With the
using mixin, you can write a class of static utility functions that pretend they are methods on Vertex. That’s what
using is for- separating sets of methods from the data they operate on, while keeping the syntax simple.
But don’t do that just because you can.
The ROPES recently presented me with an interesting problem: how can we represent memory addresses in Haxe? The ROPES’s internal data structure consists mostly of
Arrays, and I wanted two objects to exchange a reference to an
Int within an
Array, rather than its value. Haxe belongs to a family of languages that don’t support references to primitive types; they are always passed by value. What to do? (more…)