Haxe

{{Short description|Cross-platform programming language}}

{{Distinguish|Hack (programming language)}}

{{Infobox programming language

| name = Haxe

| logo = Haxe logo.svg

| paradigm = Multi-paradigm: object-oriented, functional, generic

| family = ECMAScript: ActionScript

| developer = Haxe Foundation

| released = {{Start date and age|2005|11|14}}

| latest release version = {{wikidata|property|edit|reference|P348}}

| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}

| typing = static, dynamic via annotations, nominal

| scope = lexical

| programming language = OCaml

| platform = IA-32, x86-64, AArch64, armel, armhf, MIPS, MIPS64el, MIPSel, ppc64el, RISC-V, s390x

| operating system = Android, iOS; Linux, macOS, Windows

| license = GPL 2.0, library: MIT

| file ext = .hx, .hxml

| website = {{Official URL}}

| influenced by = ECMAScript, JavaScript, ActionScript, OCaml, Java, C++, PHP, C#, Python, Lua, NekoVM

}}

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under an MIT License.{{Cite web |title=Open Source licence Haxe |url=https://haxe.org/foundation/open-source.html}} The compiler is written in OCaml. It can be run in server-mode to provide code completion for integrated development environments (IDEs).Server mode command-line: haxe --wait [host:]port

Haxe includes a set of features and a standard library[https://haxe.org/documentation/introduction/stdlib-introduction.html Introduction to the Haxe Standard Library], Haxe Docs supported across all platforms, including numeric data types, strings, arrays, maps, binary, reflective programming, maths, Hypertext Transfer Protocol (HTTP), file system and common file formats. Haxe also includes platform-specific application programming interfaces (APIs) for each compiler target.[https://haxe.org/documentation/introduction/stdlib-introduction.html#target-apis Target Specific APIs, Introduction to the Haxe Standard Library], Haxe Docs Kha, OpenFL, and Heaps.io are popular Haxe frameworks that enable creating multi-platform content from one codebase.{{cite web |last1=Doucet |first1=Lars |date=2014-06-24 |url=https://www.gamedeveloper.com/business/dear-adobe-support-haxe-save-your-tools |title=Dear Adobe: Support Haxe, save your Tools |website=Gamasutra}}

Haxe originated with the idea of supporting client-side and server-side programming in one language, and simplifying the communication logic between them.{{cite news |url=http://ncannasse.fr/blog/haxe_interview |title=Haxe Interview |publisher=Io Programmo |date=2009-04-01 |pages=1–6 |access-date=2015-08-06 |archive-date=2015-12-08 |archive-url=https://web.archive.org/web/20151208134720/http://ncannasse.fr/blog/haxe_interview |url-status=dead}} Code written in Haxe can be compiled into JavaScript, C++, Java, Java virtual machine (JVM), PHP, C#, Python, Lua{{Cite web |url=https://haxe.org/blog/hello-lua |title=Hello Lua! |website=Haxe.org}} and Node.js.{{Cite web|url=https://lib.haxe.org/p/hxnodejs |title=hxnodejs}} Haxe can also directly compile SWF, HashLink, and NekoVM bytecode and also runs in interpreted mode.{{Cite web |title=Compiler Targets |url=https://haxe.org/documentation/introduction/compiler-targets.html |website=Haxe |access-date=2021-11-05}}

Haxe supports externs (definition files) that can contain data type information of extant libraries to describe target-specific interaction in a type-safe manner, like C++ header files can describe the structure of existing object files. This enables to use the values defined in the files as if they were statically typed Haxe entities. Beside externs, other solutions exist to access each platform's native abilities.

Many popular IDEs and source code editors have support available for Haxe development.[https://haxe.org/documentation/introduction/editors-and-ides.html List of IDEs supporting Haxe], Haxe Foundation No particular development environment or tool set is officially recommended by the Haxe Foundation, although VS Code, IntelliJ IDEA and HaxeDevelop have the most support for Haxe development. The core functionalities of syntax highlighting, code completion, refactoring, debugging, etc. are available to various degrees.

History

Development of Haxe began in October 2005. The first alpha version was released on November 14, 2005.{{cite web |date=2005-11-14 |title=Release alpha-1 |website=haxe |publisher=HaxeFoundation |via=GitHub |url=https://github.com/HaxeFoundation/haxe/releases/tag/alpha-1 |access-date=2022-04-02}}{{cite mailing list |last=Cannasse |first=Nicolas |date=2005-11-17 |title=Haxe Alpha 1b |mailing-list=haXe |url=http://lists.motion-twin.com/pipermail/haxe/2005-November/000921.html |archive-url=https://web.archive.org/web/20071026065835/http://lists.motion-twin.com/pipermail/haxe/2005-November/000921.html |archive-date=2007-10-26}} Haxe 1.0 was released in April 2006, with support for Adobe Flash, JavaScript, and NekoVM programs. Support for PHP was added in 2008, and C++ was added in 2009. More platforms such as C# and Java were added with a compiler overhaul in 2012.

Haxe was developed by Nicolas Cannasse and other contributors, and was originally named haXe{{cite web |url=https://groups.google.com/d/topic/haxelang/O7PB-ZrX4i4/discussion |title=Nicolas' announcement of spelling change on Haxe official mail list}} because it was short, simple, and "has an X inside", which the author asserts humorously is needed 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 |url-status=dead |archive-url=https://web.archive.org/web/20070328232003/http://lists.motion-twin.com/pipermail/haxe/2007-March/007897.html |archive-date=2007-03-28}}

Haxe is the successor to the open-source ActionScript 2 compiler MTASC,[http://www.mtasc.org MTASC Compiler], MTASC website also built by Nicolas Cannasse and is released under the GNU General Public License version 2 or later.

Compiler

The Haxe language can compile into bytecode that can be executed directly by the virtual machines it targets. It can compile to source code in C++, JavaScript, PHP, C#, Java, Python, and Lua. Haxe also has an interpreter called eval.{{Cite web |title=Eval - The new Haxe macro interpreter |url=https://haxe.org/blog/eval/}} This same interpreter is also used compile-time to run macros, which allow modification of the abstract syntax tree (AST).

This strategy of compiling to multiple source code languages is inspired by the write once, run anywhere paradigm. It also allows the programmer to choose the best platform for the job. Typical Haxe programs run identically on all platforms, but developers can specify platform-specific code and use conditional compilation to prevent it from compiling on other platforms.

The Haxe compiler is an optimizing compiler, and uses field and function inlining, tail recursion elimination, constant folding, loop unrolling and dead code elimination (DCE) to optimize the run-time performance of compiled programs.{{Cite web|title=Compiler Features|url=https://haxe.org/manual/cr-features.html}} The Haxe compiler offers opt-in null-safety, it checks compile-time for nullable values. The run-time performance of Haxe programs is at comparable speed to handwritten sources.{{cite web|last=Dyachenko|first=Vadim|date=2013-12-05|title=On "You can't make good HTML5 games in Haxe"|url=http://yal.cc/answering-you-cant-make-good-html5-games-in-haxe/|publisher=Yellow After Life}}

See also

References

{{Reflist}}