So I was facing a dilema regarding containers I'd use in my app.
HaXe standard library provides a basic set of containers suitable for any basic use : you have Array, List and Hash. As you know haXe is a cross-targetting language and compiler, meaning that what you code can be compiled to a wide variety of plateforms, sometimes by generating code for another compiler (like g++ for C++ or Xcode for ObjC) to compile. But you should also know that what works well on C++ doesn't work as well on Flash or Php, each plateform has it's particularities.
So what does that mean for containers.
Well the most explicit example is the Flash Array. Native Flash Arrays are in fact dynamic objects in wich each index is a property. That means accessing an index of Array in Flash is slower than calculating the position of the octets in memory that represents your data like you'll do in C.
When you create an Array in haXe and target Flash, it create a Native Flash Array, so try to avoid that in critical routines.
Take the haXe List container now. It's a basic chained list, so each element you put in the list is put in an listElem, a small object that has a pointer to you element and another one to the next listElem on the list. But in List, listElems are Arrays, wich is great for almost every haXe target except Flash.
A solution to List is FastList, haXe FastList is a chained-list implementation using typed objects for listElems, therefor it's optimised for Flash, but not at all optimised for other plateforms where array is the best implementation for listElems.
A wild library appears !
ListTools is an haXe library that provides a new List implementation : SugarList.
SugarList is a compile-time resolved type that binds either to an Array based List or a kind of FastList depending of your target, that's the beauty of haXe !
Unfortunatly this library was not maintained to the latest haXe compiler version.
I could make the few changes requested for this update but right now I'm focused in getting something working, so I'll drop the flash target until I do make those changes.
No comments:
Post a Comment