Hi,
I have found a small and maybe stupid detail about Haxe, more precisely a difference between Haxe and AS3, and it could be an interesting argument.
In AS3 there is a difference between default initialization of ints and Numbers: if you declare
because Int default value is not set to 0. This is more coherent than in AS3.
Now I am asking you a personal thought: do you think it is better having default values set to 0 (for both Int/int and Float/Number etc) or you prefer to always have to specify a value, even if it is the “obvious” 0?
Personally I don’t know, the manual initialization is more… clear, explicit, but default values are in some way more natural.
Each language uses different default values. Flash uses NaN and 0, Neko uses null, Javascript uses undefined, C uses nasal demons, and so on.
It’s good that Haxe prevents the “nasal demon” scenario, because otherwise the error might go undetected until release. However, that isn’t necessary on the other targets, which all have reliable default values. And it would be a bit of a waste:
//First Javascript initializes this to undefined.
//Then Haxe sets it to 0.
private var myInt:Int;
public function new() {
//Then the class sets it to 5.
myInt = 5;
}