The Haxe Compiler employs a rich type system which helps detecting type-related errors in a program at compile-time. A type error is an invalid operation on a given type such as dividing by a String, trying to access a field of an Integer or calling a function with not enough (or too many) arguments.
In some languages this additional safety comes at a price because programmers are forced to explicitly assign types to syntactic constructs:
var myButton:MySpecialButton = new MySpecialButton(); // As3 MySpecialButton* myButton = new MySpecialButton(); // C++
The explicit type annotations are not required in Haxe, because the compiler can infer the type:
var myButton = new MySpecialButton(); // Haxe
We will explore type inference in detail later in Type Inference. For now, it is sufficient to say that the variable
myButton in the above code is known to be an instance of class
The Haxe type system knows seven type groups:
We will describe each of these type groups and how they relate to each other in the next chapters.