Language
The Haxe language is similar to ECMAScript, although almost no ECMAScript code will run on Haxe without modifications. Unlike ECMAScript, Haxe is a compiled language. It is a general-purpose language with object-oriented programming, exceptions, and type inference with class parameters. Generic classes, reflectivity, iterators, and functional programming are built-in functionality of the language and libraries. Unusual among programming languages, Haxe contains a type system which is both strong and dynamic. The compiler will check types implicitly and give compile-time errors, but it also enables the programmer to bypass type-checking and rely on the target platform's dynamic type-handling.
Since Haxe had its origins in AS3, all of the existing Flash API can be used, although Haxe requires better-formed code and programming standards than Adobe compilers (for example, with regard to scoping and data typing).
Function parameters can be defined very precisely in Haxe:
function multipleparams (threedimensionalarray : ArrayEnumerated types are a key feature of the language; they can have parameters of their own and be recursive. They are similar to algebraic data types in languages like ML or Haskell. Enums in Haxe are not simply indexed "magic-number" values as in most languages, but are more abstract: they contain no inherent value, but can be instanced into variables as in this example:
enum Color { red; green; blue; rgb: ( r : Int, g : Int, b : Int ); } class Colors { static function toInt ( c : Color ) : Int { return switch ( c ) { case red: 0xFF0000; case green: 0x00FF00; case blue: 0x0000FF; case rgb(r, g, b): (r << 16) | (g << 8) | b; } } static function validCalls { var redint = toInt(Color.red); var rgbint = toInt(Color.rgb(100,100,100)); } }This example draws a red square using a Flash MovieClip object, and utilizes the "using" keyword.
using Colors; class Test { static function main { var mc: flash.display.MovieClip = flash.Lib.current; mc.graphics.beginFill(red.toInt); mc.graphics.moveTo(50,50); mc.graphics.lineTo(100,50); mc.graphics.lineTo(100,100); mc.graphics.lineTo(50,100); mc.graphics.endFill; } }Read more about this topic: Ha Xe
Famous quotes containing the word language:
“The problems of society will also be the problems of the predominant language of that society. It is the carrier of its perceptions, its attitudes, and its goals, for through it, the speakers absorb entrenched attitudes. The guilt of English then must be recognized and appreciated before its continued use can be advocated.”
—Njabulo Ndebele (b. 1948)
“Language is filled
with words for deprivation
images so familiar
it is hard to crack language open
into that other country
the country of being.”
—Susan Griffin (b. 1943)
“What distinguished man from animals was the human capacity for symbolic thought, the capacity which was inseparable from the development of language in which words were not mere signals, but signifiers of something other than themselves. Yet the first symbols were animals. What distinguished men from animals was born of their relationship with them.”
—John Berger (b. 1926)