What is Haxe and should I care about it?
Tags: haxe, typescript, gamedev, haxeflixel
Published: 2019-07-16 07:20:15

---
title: What is Haxe and should I care about it?
published: true
description: 
tags: haxe, typescript, game dev, haxeflixel
---

I've been developing a game in [Haxe](https://haxe.org/) for the past 6 months and I really enjoyed using it. Coming from a frontend, [Javascript](https://developer.mozilla.org/en-US/docs/Web/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](https://en.wikipedia.org/wiki/Haxe). 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](https://dev.to/khaled_garbaya/do-you-know-haxe-1he9), Haxe supports over 8 different languages, which is pretty cool.

![](https://thepracticaldev.s3.amazonaws.com/i/8ntmp8nff1z1fb7tvpvq.jpg)

Haxe itself was released in 2006, is an open-source, strongly types language which looks very similar to [ActionScript](https://en.wikipedia.org/wiki/ActionScript) or [Typescript](https://en.wikipedia.org/wiki/Microsoft_TypeScript) so should look familiar to those who have experience with either languages.


```ts
// TypeScript
function greet(name?:string):string {
    if (name) {
        return "Hello, " + name;
    } else {
        return "Hello";
    }
}
```

```hx
// 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](https://blog.onthewings.net/2015/08/05/typescript-vs-haxe/))*

## 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](https://flutter.dev/) and [React Native](https://facebook.github.io/react-native/) that are better suited for those things. Game development is the most popular reason most people use Haxe. 


![Haxe 2018 survey results](https://haxe.org/img/blog/2019-03-01-haxe-2018-survey-results/pie-group-usages.png)
*(Haxe 2018 survey results)*


## Why I use Haxe for games?
Unlike other popular game development engines ([Unity](https://unity.com/), [Unreal Engine](https://www.unrealengine.com/en-US/), [Gamemaker](https://www.yoyogames.com/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](https://code.visualstudio.com/)) 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](https://www.npmjs.com/) for Javascript packages, [Haxelib](https://lib.haxe.org/) 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](https://armory3d.org/) and [Stencyl](http://www.stencyl.com/), 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.