loading...

What is Haxe and should I care about it?

richardbray profile image Richard Oliver Bray Updated on ・4 min read

I've been developing a game in Haxe for the past 6 months and I really enjoyed using it. Coming from a frontend, Javascript, web background it's been fun to dig deep into a new language and Haxe is such a great stepping stone for that since the syntax is so similar. Unlike the Javascript community, the Haxe one is quite small, which means there aren't many people talking about it online. I'm hoping to increase the buzz around Haxe going forward with this post and many others in the future.

What is Haxe?

There are loads of official explanations of this online and if that's the sort of thing you're looking for you can find that here. But I'm going to give a simple answer to that question which is, Haxe is a language that was built to be transpiled or compiled into other languages, that's it. One language for many platforms. So you can write a piece of code in Haxe and use that same code in a Javascript project, a Python one, a Java one or a C++ one. In fact, according to this article, Haxe supports over 8 different languages, which is pretty cool.

Haxe itself was released in 2006, is an open-source, strongly types language which looks very similar to ActionScript or Typescript so should look familiar to those who have experience with either languages.

// TypeScript
function greet(name?:string):string {
    if (name) {
        return "Hello, " + name;
    } else {
        return "Hello";
    }
}
// Haxe
function greet(?name:String):String {
    if (name != null) { // no implicit conversion to Bool
        return "Hello, " + name;
    } else {
        return "Hello";
    }
}

(Code samples taken form here)

Should I care about it?

As I mentioned in the first paragraph my programming experience prior to Haxe was largely based on frontend technologies (HTML,CSS and JS). So the answer to this question from that point of view would be, not really. If you are a developer who is happy and knowledgeable with the languages you already use and have no interest in trying something different, then you don't really need to know of or care about Haxe. However, if you're a curious developer, want to see what else is out there and most importantly, have an interest in game development, then you should definitely care about Haxe.

Yes, the Haxe website does say you can use it for web and mobile development, I personally haven't used it for that before as there are cross-platform tools out there like Flutter and React Native that are better suited for those things. Game development is the most popular reason most people use Haxe.

Haxe 2018 survey results
(Haxe 2018 survey results)

Why I use Haxe for games?

Unlike other popular game development engines (Unity, Unreal Engine, Gamemaker), Haxe doesn't have a GUI, it's just a programming language. So if you're fluent in a certain IDE (cough VS Code) you don't have to switch, just run a few commands in the terminal and you can begin making games. Well, it's not that simple, as usual, you'll need to install some packages first. Like NPM for Javascript packages, Haxelib is the package manager for Haxe.

Actually, let me rephrase the above paragraph slightly to avoid being corrected in the comments. There are some game engines built on Haxe that do have a GUI i.e. Armory and Stencyl, but generally, game development with Haxe is done in a code editor. Phew.

Another reason I enjoy using Haxe for game dev is that it's small, much smaller than I expected. The latest version at the time of writing (4.0.0-rc.3) is under 10MB which, from experience was much quicker to download and install compared to other programming languages. Haxe is completely free, no hidden costs for specific targets or amount of copies sold of your game just free, which is ideal for those who develop games for a hobby.

Now, of course, it's highly unlikely one would create a game with vanilla Haxe code. It's more common to use a game framework or engine with Haxe. For my games, I chose to use HaxeFlixel mainly because of its great documentation, examples, and ease of use but there are many others. I'm planning to do a writeup on it in the future.

Final words

In conclusion, if you're currently a web developer that wants to try making a game that works natively on Windows, Mac, Linux, Android, iOS, or even consoles, you should definitely check out Haxe. There's no cost, it's easy to integrate into your workflow, and it looks very similar to Typescript.

Posted on by:

richardbray profile

Richard Oliver Bray

@richardbray

Front end developer @OctopusLabs. Making games in Haxeflixel @hello_lightbulb. Novice photographer and player of video games.

Discussion

markdown guide
 

I'm a big fan of Haxe. I've used it to make some Android games back in 2014 and even cli programs.