ArticleslgStudy

computer science

Haxe

Haxe is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Haxe rather than just read about it. In short: 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 a GPL v2.0 license (the standard library and Neko virtual machine are under the MIT License).

Haxe — main illustration
Haxe — illustration

Key takeaways

  • Haxe belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Haxe to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Haxe from memory before moving on to harder problems.

Reference excerpt

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 a GPL v2.0 license (the standard library and Neko virtual machine are under the MIT License). The compiler is written in OCaml. It can be run in server-mode to provide code completion for integrated development environments (IDEs). Haxe includes a set of features and a standard library 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. 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, C++, Java, Java virtual machine (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, 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, 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. 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) Nim (programming language) Opa (programming language) Clojure CoffeeScript TypeScript Scala (programming language) Vala (programming language) Emscripten OpenFL

References

External links Official website

Illustrations

Haxe illustration

Worked examples

Example 1 — a first encounter with Haxe

Start with the simplest possible case. Write down what Haxe claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Haxe before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Haxe ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Haxe

In research
Haxe appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Haxe in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Haxe is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free software programmed in OCaml, Functional languages, High-level programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Haxe outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Haxe in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Haxe means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Haxe out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Haxe in simple terms?

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 a GPL v2.0 license (the standard library and Neko virtual machine are un…

Why does Haxe matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Haxe?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Haxe.

Tags

  • Free software programmed in OCaml
  • Functional languages
  • High-level programming languages
  • Multi-paradigm programming languages
  • Object-based programming languages
  • Pattern matching programming languages
  • Programming languages
  • Programming languages created in 2005
  • Software using the GNU General Public License
  • Software using the MIT license
  • Source-to-source compilers
  • Statically typed programming languages

Keep exploring