Getting Started With HaXe and NME

Haxe shows great promise with its C/Java like syntax and cross platform ability, but at first glance it seems like it's lacking in documentation. However, there are many tutorials on how to setup HaXe and NME, so I'm going to skip ahead and get directly down to business.

Writing our First HaXe Application

Let's build our first Hello World program in haxe, woo! First we need to create a helloworld directory with a file called Main.hx. Next we will want to create a class called Main, which directly correlates to the filename.

So we have our class, but we need something to trigger the Hello World text. Thus, we need to create the main funciton.

Wonderful! Now that we've setup haxe, it's time to print out Hello World. Haxe gives us the ability to log information using the trace command. You will want to read up on the different ways it outputs depending on the target device. For this demo we will be targeting Neko, a console program.

Building the App

So you have your shinny new haxe program, awesome, but no way to see the output. Well, we are going to build the app via command line. It takes two commands, one to build and one to actually output the app. So open up your terminal and type the following:

Now that we build our application, lets output it.

You should see our infamous Hello World! If you have any troubles, google it, or you can search HaXes or NME's forums.