<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Game Haxe &#187; source</title>
	<atom:link href="http://gamehaxe.com/tag/source/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamehaxe.com</link>
	<description>Experimenting with Web Game Development</description>
	<lastBuildDate>Fri, 17 Jun 2011 01:24:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>C++ backend for haXe</title>
		<link>http://gamehaxe.com/2008/10/28/c-backend-for-haxe/</link>
		<comments>http://gamehaxe.com/2008/10/28/c-backend-for-haxe/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:44:24 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[neash]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=87</guid>
		<description><![CDATA[I have just completed an alpha release of a c++ backend for haxe. This means that you can complile haxe code into a 100% compiled executable. You can download the demo file in hxcpp-01.zip. Sorry, windows only at this stage. &#8230; <a href="http://gamehaxe.com/2008/10/28/c-backend-for-haxe/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have just completed an alpha release of a c++ backend for haxe.  This means that you can complile haxe code into a 100% compiled executable.  You can download the demo file in <a href="http://gamehaxe.com/wp-content/uploads/hxcpp-01.zip">hxcpp-01.zip</a>.  Sorry, windows only at this stage.</p>
<p>The distribution contains a new cpp backend for haxe. It has been based on a 2.0 version of haxe, which may be a tiny bit out of date.  Most of the changes are in the new &#8220;gencpp.ml&#8221;, and to the standard library files, with a few little extra bits here and there.  You can re-compile the<br />
haxe compiler if you have ocaml by using the supplied install.ml script.</p>
<p>To try this version for yourself, first backup your haxe distro and copy then supplied &#8220;compile/bin/haxe.exe&#8221; and &#8220;compiler/std/*&#8221; files over the top. Use the &#8220;-cpp cpp_directory&#8221; command line to generate a directory that contains src, include and nmake files.  You can then compile these using the microsoft visual studio &#8220;nmake&#8221; utility.  The build system requires the library, include, make and dlls from the &#8220;hxcpp&#8221; directory.  To access these, you should set the environment variable &#8220;HXCPP&#8221; to point to hxcpp directory extracted from this distribution.  This can be done from right-click-&#8221;My Computer&#8221;/Properties/Advanced/Environment Variables, or from the commandline before compiling.<br />
These resulting &#8220;exe&#8221; file also needs the hxcpp.dll file from the hxcpp/dll directory.  The should be in your &#8220;path&#8221;, or simply copy it next to your exe.</p>
<p>You can recompile the hxcpp.dll using the nmake file in the directory.  You can change the compile flags from the $HXCPP/nmake.setup file (eg, turn on debug).</p>
<h2>Demos</h2>
<p>Two demos have been included &#8211; &#8220;perf&#8221;, a small benchmark program I found on the net<br />
and a &#8220;Physaxe&#8221; demo.  The source is included (slightly modified), and so are the binaries.<br />
The cpp src and include directories have been included to give you taste of the<br />
output if you can&#8217;t be bothered setting up the compiler yourself.<br />
The binaries can be found in demos/bin, and are compiled for neko, swf and cpp.<br />
The neko version can be run with &#8220;neko phx.n&#8221; or &#8220;neko TestRunner.n&#8221;.  You do not<br />
need a very recent version of neko, but you do need the included &#8220;nme.ndll&#8221; findable<br />
by neko (next to it will work).</p>
<p>The cpp version of Physaxe uses the cpp verion of NME.  This was compiled from<br />
the same code base as the neko version, except it uses the &#8220;neko.h&#8221; file found<br />
in the hxcpp directoty instead of the one that comes with neko.  The nme.dll should<br />
be next to the compiled exe.</p>
<p>If you want to compile the nme versions yourself, you will need the latest nme and neash<br />
versions from code.google.com:</p>
<p>http://code.google.com/p/nekonme/source/checkout</p>
<p>http://code.google.com/p/neash/source/checkout</p>
<p>Performance<br />
&#8212;&#8212;&#8212;&#8212;<br />
The flash version of physaxe runs the fastest, with the cpp version about 70% of the<br />
speed (when using the opengl version), and neko about 20% of the speed.</p>
<p>One of the problems is that the cpp version uses the neko api, which required fields<br />
to be looked up by name, which is quite slow in this implementation. A faster version<br />
could link directly to the hxcpp objects &#8211; but then it could not use the same API.<br />
This problem is made far worse by the fact the physaxe re-renders each point in each<br />
object every frame, rather then simply adjusting the matrix of existing objects.</p>
<p>I think the most significant loss of perfromance is coming from the reference counting<br />
housekeeping.  I will look into a garbage collected system soon.</p>
<p>The results from the &#8220;TestRunner&#8221; are mixed with flash being faster for stings, but<br />
cpp faster for maths and looping.  Neko is fastest for the sting sort in this case,<br />
but this is unusual because the stings are already sorted.  When they are not, neko<br />
is very slow.  The cpp string code is very simple, so there is scope for improvement there.</p>
<p>TODO<br />
&#8212;-<br />
There is still plenty to do.</p>
<ul>
<li> A lot of the operators (eg, &#8220;*=&#8221;) have not been looked at. </li>
<li> The actual formatting of the generated code needs a complete overhaul. </li>
<li> The ml code needs some simplifying/cleaning. </li>
<li> The standard libraries (eg, xml,regex) </li>
<li> Need some way of locating the various dlls etc. </li>
<li> Splitup/refactor the HObject.h et al files. </li>
<li> Returning values from blocks/swithes. </li>
<li> Complete neko.h </li>
<li>Look at GC. </li>
</ul>
<p>Plenty more, I&#8217;m sure.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2008/10/28/c-backend-for-haxe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

