Haxe is a
high-level cross-platform
Within computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several Computing platform, computing platforms. Some ...
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
and
compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
that can produce applications and
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
for many different
computing platforms from one code-base. It is
free and open-source software, released under an
MIT License
The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility.
Unl ...
. The compiler is written in
OCaml. It can be run in server-mode to provide code completion for
integrated development environment
An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
s (IDEs).
Haxe includes a set of features and a
standard library[Introduction to the Haxe Standard Library](_blank)
Haxe Docs supported
across all platforms, including
numeric data types,
strings,
arrays
An array is a systematic arrangement of similar objects, usually in rows and columns.
Things called an array include:
{{TOC right
Music
* In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
,
maps,
binary,
reflective programming, maths, Hypertext Transfer Protocol (
HTTP
HTTP (Hypertext Transfer Protocol) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, wher ...
), file system and common
file format
A file format is a Computer standard, standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary format, pr ...
s. Haxe also includes platform-specific application programming interfaces (
APIs) for each compiler target. ''Kha'', ''
OpenFL'', and ''Heaps.io'' are popular Haxe frameworks that enable creating multi-platform content from one codebase.
Haxe originated with the idea of supporting
client-side and
server-side programming in one language, and simplifying the communication logic between them.
Code written in Haxe can be
compiled into
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
,
C++,
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
Java virtual machine
A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
(JVM),
PHP,
C#,
Python,
Lua and
Node.js. Haxe can also directly compile
SWF, HashLink, and
NekoVM bytecode and also runs in interpreted mode.
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. 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.
Haxe 1.0 was released in April 2006, with support for
Adobe Flash,
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
, 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''
because it was short, simple, and "has an X inside", which the author asserts humorously is needed to make any new technology a success.
Haxe is the successor to the open-source
ActionScript 2 compiler
MTASC,
[MTASC Compiler](_blank)
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 computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
in
C++,
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
,
PHP,
C#,
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
Python, and
Lua. Haxe also has an interpreter called ''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.
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.
See also
*
Dart (programming language)
Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications.
Dart is an object-oriented, class-based, garbage-colle ...
*
Nim (programming language)
*
Opa (programming language)
*
Clojure
*
CoffeeScript
CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Some added features include list comprehension an ...
*
TypeScript
*
Scala (programming language)
*
Vala (programming language)
*
Emscripten
*
OpenFL
References
External links
*
{{ML programming
High-level programming languages
Functional languages
Multi-paradigm programming languages
Object-based programming languages
OCaml software
Pattern matching programming languages
Programming languages
Programming languages created in 2005
Software using the GNU General Public License
Source-to-source compilers
Statically typed programming languages
Articles with example JavaScript code