

Using Haxe with Unity3D - jdk
http://blog.proletariat.com/post/63641237563/free-hugs

======
Hemospectrum
Haxe is kind of a spiritual successor to ActionScript, as envisioned by OCaml
developers (the compiler is written in OCaml). It was originally aimed at
Flash, but these days it compiles to everything under the sun, and there are
libraries like OpenFL (sic) and HaxePunk to take advantage of this for cross-
platform game development. That includes native code generation, via C++, for
desktop and iOS targets. It's a neat piece of tech.

~~~
jdk
The previous post on the blog actually talked about WHY we picked Haxe to do
client/server development so we didn't have to write a ton of duplicate code.
As a bonus, it's just a great language with a good community and active
developers.

~~~
teamonkey
That 20% speed boost on iOS through inlining seems more than reason enough.
Can you go in to more detail? Why isn't the C# compiler smart enough to do
this?

~~~
jdk
C# chose to leave this up to the JIT/VM to implement, rather than compiler.
Both Microsoft and Mono's .NET runtime will choose to inline functions based
on some heuristics. (see [http://stackoverflow.com/questions/473782/inline-
functions-i...](http://stackoverflow.com/questions/473782/inline-functions-
in-c)).

However, the (old, forked) version of Mono used by Unity does not appear to
inline functions - at least not when using the ahead-of-time compilation
required to run on iOS.

------
Pxtl
Since Haxe looks like it was made with cross-platform gaming in mind, how does
it deal with GC issues? How hard is it to use when you have to go into that
"no create or destroy" main-loop? I assume this varies depending on target
platform.

~~~
jdk
Haxe is a garbage-collected language, and in general, it uses the GC of the
target platform (the C++ target includes a runtime with a conservative
collector). So you'll run into the typical issues with writing game code in a
GC language - being careful about allocations and deep reference hierarchies,
pooling/reusing objects, etc. Haxe doesn't really change anything here.

Haxe does expose some platform-specific features that help though, such as C#
structs and pointers/unsafe code, as well as platform-specific API's for
interacting with the garbage collector (e.g.
[http://api.haxe.org/cpp/vm/Gc.html](http://api.haxe.org/cpp/vm/Gc.html)). You
can take advantage of these while still writing cross-platform code with the
usual tricks of conditional compilation.

------
sjsivak
The most important part of this post is the github repository:
[http://github.com/proletariatgames/HUGS](http://github.com/proletariatgames/HUGS)

"This library includes Haxe externs for Unity and .NET frameworks, generated
via the cslibgen utility. It also includes the HUGSWrapper "using" class,
which includes various things to work around Haxe/C# translation issues, as
well as make working with Unity easier."

------
ddorian43
I FUCKING HATE when the trailer doesn't show ingame play, but useless rendered
cgi.

~~~
wtetzner
What trailer? How is this relevant to Haxe?

~~~
ddorian43
The trailer of the game they are developing using Haxe. The comments doesn't
have to be relevant to Haxe. If you go at their homepage you can see the
trailer.

Since their goal is to sell the game i think my comment is relevant (maybe
harsh by looking at the votes).

~~~
sjsivak
Here is the demo we showed at PAX Prime back in August:
[http://www.youtube.com/watch?v=rj4aa9dhKdo](http://www.youtube.com/watch?v=rj4aa9dhKdo)

