Notes on Haxe

John Gabriele

2018-08

Some very rough, nascent, and incomplete ramblings on Haxe.

Links

Languages comparable to Haxe include Dart, Kotlin, Reason, and Swift.

Getting Started

Install

More info at the Haxe Download for Linux page.

# apt install haxe
# exit
$ man haxe
$ man haxelib
$ mkdir ~/haxelib
$ haxelib setup
$ haxe    # Shows some help text.

Editor Setup

Geany works out of the box. The Emacs Haxe mode is pretty old.

Hello World

Create a Main.hx file:

class Main {
    static public function main() {
        trace("Hello, World!");
    }
}

then run it directly using the built-in interpreter:

haxe -main Main --interp

Or, cross-compile the file and run it. For example, using Python:

haxe -main Main -python main.py
python3 main.py

Note: Haxe now has its own VM called HashLink.

Haxelib

The Haxe online package repo and library management tool is haxelib (see the haxelib docs). The haxelib command comes with the Haxe Debian software package when you apt install it.

Packages/projects you install via haxelib are often named lowercase with hyphens if necessary. The package files themselves are .zip files, and its haxelib.json file is the package config file.

Haxelib installs and unpacks packages into ~/haxelib. This is your haxelib installed-packages repo. Haxelib can also do project-specific repos.

Language Basics