HaXe

HaXe

Infobox programming language
name = haXe
paradigm = object-oriented, structured, scripting
year = 2005
developer = Nicolas Cannasse
latest_release_version = 2.0
typing = static
operating_system = Cross platform
website = [http://haxe.org/ haxe.org]
influenced_by = Javascript, OCaml

haXe is a programming language, designed for creating interactive web applications. Currently there are four official compiler targets - Adobe Flash, JavaScript, PHP and the Neko VM.cite web |url=http://haxe.org/doc/intro |title=haXe introduction page]

History

Development of haXe was started on the 22nd of October, 2005. The first alpha version of haXe was released on the 14th of November, in the same year. The first beta version was released on the 4th of February, 2006. haXe 1.0 was released on the 17th of April, in the same year. The current release of haXe is version 2.0, which was released on the 28th of July, 2008.cite web |url=http://lists.motion-twin.com/pipermail/haxe/2008-July/018154.html |title=haXe 2.0 release]

haXe is released under the GNU General Public License.cite web |url=http://haXe.org/download |title=haXe download page]

Naming and pronunciation

The name haXe (pronounced as hex) was chosen because it is short, easy, cool, and "has an X inside", which the author claims is necessary to make any new technology a success.cite web |url=http://lists.motion-twin.com/pipermail/haxe/2007-March/007897.html |title=haXe mailing list post on naming]

Language

The header of the official haXe site describes haXe as a "web oriented universal language." The feature that is tied to this description is the compiler's ability to target different virtual machines: Adobe Flash's AVM1(Flash 6-8) and AVM2(Flash 9+), Javascript, and NekoVM, the last being a general-purpose virtual machine also built by haXe creator Nicolas Cannasse. The haXe language and libraries are designed to achieve maximal support of these target platforms, and the compiler will emit target source or bytecode depending on the language and options selected. The "web oriented universal" moniker follows from this ability to deploy the same code across different layers of a WWW application. The haXe community has shown interest in adding PHPcite web|url=http://lists.motion-twin.com/pipermail/haxe/2008-February/014158.html |title=PHP discussion thread] and Javacite web|url=http://lists.motion-twin.com/pipermail/haxe/2005-December/001008.html |title=Java discussion thread] support.

haXe 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.cite web |url=http://haXe.org/ref |title=haXe language reference] 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.

Function parameters can be defined very precisely in haXe:

function multipleparams(threedimensionalarray : Array>>, stringval : String, boolval : Bool) {}function optionalargument( ?i : Int ) : Int {return 0;} // optional int value returning an intfunction functionasparameter( f : Void -> Void ) {f();} // call a function with no parameters function anotherfunctionparm( f : Int -> Int ) {var result = f(1);} // call a function that returns an int, with an int parameterfunction icoulddoanything(d : Dynamic) : Dynamic {return d;} // function which takes any kind of type and returns it

Enumerated types are a key feature of the language, they can have parameters of their own and be recursive, which allows them to be treated like classes.cite web |url=http://haxe.org/ref/enums |title=haXe reference detailing the use of enum] 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: 0xFF000; case green: 0x00FF00; case blue: 0x0000FF; case rgb(r,g,b): (r << 16) | (g << 8) | b; } } static function validCalls() { var redint = toInt(red); var rgbint = toInt(rgb(100,100,100)); } } (Modified from the haXe Reference)

Demonstrating haXe for graphical uses, here is some example code for the Adobe Flash target (from the haXe website):

class Test { static function main { var mc : flash.MovieClip = flash.Lib.current; mc.beginFill(0xFF0000); mc.moveTo(50,50); mc.lineTo(100,50); mc.lineTo(100,100); mc.lineTo(50,100); mc.endFill(); } }

This will draw a square using a Flash MovieClip object.

Compiler implementation and performance

The haXe compiler is implemented in the OCaml language. Because haXe-generated code runs on virtual machines, no knowledge of OCaml is necessary to develop applications using haXe. This also means that benchmark performance varies depending on the target platform, as each platform must be customized to make the best use of available features.

One benchmarkcite web|url=http://gamehaxe.com/2007/12/01/cross-platform-again/ | title=AS3->haXe port of the Actionscript Physics Library] indicates that haXe compiles Flash 9(AVM2) bytecode with better performance than the equivalent AS3 code on Adobe's compiler. Since this benchmark the compiler has further improved performance features with the addition of inline functions.

References

External links

* [http://haXe.org Official haXe website]
* [http://www.amazon.com/Professional-HaXe-Neko-Programmer/dp/0470122137/ref=sr_1_1?ie=UTF8&s=books&qid=1222978545&sr=8-1 Official haXe book]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • HaXe — Entwickler: Motion Twin Aktuelle Version: 2.0 Betriebssystem: Windows, Linux, Mac OS X Kategorie: Programmierspr …   Deutsch Wikipedia

  • HaXe — est un langage de programmation développé par Nicolas Cannasse et la société Motion Twin qui permet l utilisation : du côté du serveur : un langage Web comme le PHP, Perl, Ruby ou Python. du côté du client : Flash (ActionScript 1,… …   Wikipédia en Français

  • Haxe — est un langage de programmation développé par Nicolas Cannasse et la société Motion Twin qui permet l utilisation : du côté du serveur : un langage Web comme le PHP, Perl, Ruby ou Python. du côté du client : Flash (ActionScript 1,… …   Wikipédia en Français

  • HaXe — Класс языка: Мультипарадигмальный Появился в: 2005 Расширение файлов: .hx Релиз: 2.10 Типизация данных: Статическая …   Википедия

  • haXe — est un langage de programmation développé par Nicolas Cannasse et la société Motion Twin qui, dans le cadre d’une utilisation pour le Web, permet d’écrire la partie serveur et la partie client dans un même langage. À cette fin, haXe permet… …   Wikipédia en Français

  • haXe — универсальный объектно ориентированный язык программирования высокого уровня. Автором и основным разработчиком платформы является французская медийная компания Motion Twin, которая так же известна как разработчик предшественника haXe mtasc… …   Википедия

  • Haxe — ist eine alternative Schreibweise für: Hachse, in der Küchensprache der Unterschenkel eines Schweins oder eines anderen Huftieres. haXe, eine objektorientierte Programmiersprache, welche andere Programmiersprachen wie ActionScript, Javascript… …   Deutsch Wikipedia

  • Haxe — (Hachse, Hechse), s. Hesse …   Meyers Großes Konversations-Lexikon

  • Haxe — Haxe(Haxn)f(m) 1.Bein.MeinteigentlichdenKniebugdesHinterbeinsbeiTieren.AufdenMenschenübertragenim17.Jh.,vorwiegendoberd. 2.sichdieHaxenablaufen=vieleWegemachen.⇨Bein22.Seitdem18.Jh. 3.sicheineHaxeausreißen=sichabplagen.⇨Bein28.Oberdseitdem19.Jh.… …   Wörterbuch der deutschen Umgangssprache

  • Haxe — Sf Hachse …   Etymologisches Wörterbuch der deutschen sprache

  • Haxe — Haxe, Hechse ↑ Hachse …   Das Herkunftswörterbuch

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”