<?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>haxe &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/haxe/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Fri, 17 Sep 2010 07:05:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>haxe &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Haxe got (awesome) macros!</title>
		<link>https://blog.sephiroth.it/2010/09/17/haxe-got-awesome-macros/</link>
					<comments>https://blog.sephiroth.it/2010/09/17/haxe-got-awesome-macros/#respond</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 17 Sep 2010 07:05:46 +0000</pubDate>
				<category><![CDATA[general]]></category>
		<category><![CDATA[ast]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[dls]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[macros]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=1374</guid>

					<description><![CDATA[Hi guys, It has been a while since I posted the last time. However I felt like it was the right moment to go back on the blog, to talk you about the new awesome Haxe macro system. As you can read on Nicolas&#8217;s blog, they&#8217;re only present in the latest SVN update, but they &#8230; <a href="https://blog.sephiroth.it/2010/09/17/haxe-got-awesome-macros/" class="more-link">Continue reading <span class="screen-reader-text">Haxe got (awesome) macros!</span></a>]]></description>
										<content:encoded><![CDATA[<p>Hi guys, It has been a while since I posted the last time. <br />
However I felt like it was the right moment to go back on the blog, to talk you about the new awesome Haxe macro system.</p>
<p>As you can <a href="http://ncannasse.fr/blog/haxe_got_macros">read</a> on Nicolas&#8217;s blog, they&#8217;re only present in the latest SVN update, but they will be included in the next build as soon as they will be perfect.<br />
 I must say I&#8217;m extremely happy about that addition: one of the most important reasons I&#8217;m so happy is the fact that instead of implementing an old-and-bording Macro system ala C/C++, Nicolas decided to go for a much more powerful macro system, which allows typesafe macros and real runtime code generation.</p>
<p>You are not limited to simple stuff like replace a macro call with a block of source code, but you can generate any kind of valid AST expressions that will be evaluated by the macro preprocessor at compile time. <br />
Moreover you have access to almost the whole neko library (io, net, etc) which means you can write extremely powerful code generators and DSL!  That&#8217;s an awesome feature &#8211; really.</p>
<p>Give it a look!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2010/09/17/haxe-got-awesome-macros/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Expressions evaluation at (almost) native speed</title>
		<link>https://blog.sephiroth.it/2008/07/01/expressions-evaluation-at-almost-native-speed/</link>
					<comments>https://blog.sephiroth.it/2008/07/01/expressions-evaluation-at-almost-native-speed/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Wed, 02 Jul 2008 00:00:00 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[scripting languages]]></category>
		<category><![CDATA[applicationDomain]]></category>
		<category><![CDATA[bytecode]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[HxASM]]></category>
		<category><![CDATA[swfcompiler]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=257</guid>

					<description><![CDATA[Finally I found a bit of time this weekend to do some other tests with expressions evaluation. The results are pretty interesting, even if obvious from some point of view. I took the ExpressionEvaluator I wrote as example for the first post about this topic, and then I edited a bit the code adding just &#8230; <a href="https://blog.sephiroth.it/2008/07/01/expressions-evaluation-at-almost-native-speed/" class="more-link">Continue reading <span class="screen-reader-text">Expressions evaluation at (almost) native speed</span></a>]]></description>
										<content:encoded><![CDATA[<p>Finally I found a bit of time this weekend to do some other tests with <strong>expressions evaluation</strong>.</p>
<p>The results are pretty interesting, even if obvious from some point of view. I took the ExpressionEvaluator I wrote as example for the <a title="Runtime expression evaluation in ActionScript" href="https://blog.sephiroth.it/2008/04/19/runtime-expression-evaluation-in-actionscript/">first post</a> about this topic, and then I edited a bit the code adding just in time <strong>AS Bytecode compilation</strong>.<br />
Thanks to that, expressions evaluation is much more fast and always safe because it runs in its own <em>ApplicationDomain</em>.</p>
<p>You can <a href="https://blog.sephiroth.it/wp-content/uploads/2008/07/ExpressionEvaluator_compiler.zip">download the sources here</a>, that includes the edited code and a test file. <strong>The test file runs 1 milion of iterations and may hang your browser or at worst case your system. Reduce the value of the ITERATIONS constant if you are not sure about the power of you machine</strong>.</p>
<p>If you want to read a bit more details about that, click on the link below to continue reading.</p>
<p><span id="more-257"></span></p>
<p>I did some simple modification to the existing classes:</p>
<ul>
<li>Added a <em>compile</em> method to the IExpression interface;</li>
<li>Added the <em>symbolNames</em> getter to the SymbolTable class, to retrieve a list of all the symbols defined inside the symbol table.</li>
<li>Converted hxasm to Actionscript (finxing some small issues to avoid to include all the Haxe support classes);</li>
<li>Implemented the <em>compile</em> method on all the AST nodes using HxASM;</li>
<li>Added an <em>SWFCompile</em> class that takes an IExpression and a SymbolTable and produces an SWF;</li>
<li>Edited the <em>CompiledExpression</em> class adding a <em>compile</em> method that generates an SWF starting from an <em>IExpression</em>.</li>
</ul>
<p>Adding just in time compilation was easy a really quick thanks to <a href="http://haxe.org/com/libs/hxasm">HxASM</a>. <strong>HxASM</strong> is an <a href="http://haxe.org">Haxe</a> library written by Haxe&#8217;s author (<strong>Nicolas Cannasse</strong>) that makes you able to write low level bytecode instructions in ActionScript an generate a <em>ByteArray</em> that contains an (hopefully) valid SWF. The SWF can then be loaded by <em>Loader.loadBytes</em> and executed.</p>
<p>It have been easy to port HxASM to ActionScript too, thanks again to the <strong>Haxe compiler which is able to generate AS3 code starting from Haxe code</strong>.</p>
<p>Compilation was achieved easilly because the expressions we are compiling are really simple. The compiler generates a class called <em>CompiledExpression</em> that has a method <em>execute</em> that can be called to execute the expression. All the values inside the symbol table are exposed as public properties.</p>
<p>Just to make you understand better, givin this expression:</p>
<p><code>sin( x * 10 + y - 11 )</code></p>
<p>SWFCompiler will generate the bytecode for this class:<br />
<code lang="actionscript">class CompiledExpression<br />
{<br />
public var sin: *;<br />
public var x: *;<br />
public var y: *;<br />
public function execute(): Number<br />
{<br />
return sin( x * 10 + y - 11 );<br />
}<br />
}</code><br />
As you can see the type of the class variables is generic, but you can improve the generator to understand if a variable should contain a number or a function.</p>
<p>The generated SWF can be loaded and run easilly:<br />
<code lang="actionscript">var loader: Loader = new Loader();<br />
var parser: Parser = new Parser(<br />
new Scanner( "sin( x / ( 4 / 2 * 2 - 2 + 2 * x / x ) ) * 100" ) );<br />
var compiled: CompiledExpression = parser.parse();<br />
var data: ByteArray = compiled.compile();<br />
loader.contentLoaderInfo.addEventListener( Event.COMPLETE,<br />
function( event: Event ): void<br />
{<br />
var info: LoaderInfo = ( event.target as LoaderInfo );<br />
var klass: Class = (<br />
info.applicationDomain.getDefinition( "CompiledExpression" ) as Class );<br />
var cp: Object = new klass();<br />
cp.x = 10;<br />
cp.sin = Math.sin;<br />
trace( "Result", cp.execute() );<br />
} );<br />
loader.loadBytes( data, new LoaderContext( false,<br />
new ApplicationDomain( ApplicationDomain.currentDomain ) ) );<br />
</code><br />
I build a simple test (shipped with the sources) that runs 1 milion times an expression using 3 methods: Evaluation, Compiled and Native.</p>
<p>Results (on my Mac Pro 8 Core, 4GB ram) are obvious:</p>
<pre>eval 1000000 iterations: 12939
<strong>compiled 1000000 iterations: 848</strong>
native 1000000 iterations: 371</pre>
<p>As you can see native execution is faster, but compiled version runs really well (you might want to optimize the generated code to make it run faster) and it is many times faster then AST evaluation.</p>
<p>If you want to run a complex expression many times and dont want to stress your Flash Plugin, you can use the compiled version.</p>
<p>Gotta run, see u next time!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2008/07/01/expressions-evaluation-at-almost-native-speed/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>From Web to Desktop</title>
		<link>https://blog.sephiroth.it/2006/09/01/from-web-to-desktop/</link>
					<comments>https://blog.sephiroth.it/2006/09/01/from-web-to-desktop/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 01 Sep 2006 18:55:36 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe labs]]></category>
		<category><![CDATA[apollo]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[neko]]></category>
		<category><![CDATA[screenweaver]]></category>
		<category><![CDATA[swhx]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=166</guid>

					<description><![CDATA[Yesterday Screenweaver HX was announced as part of the haxe framework. With SWHX, you create an application by using two layers : the System layer : written in haXe and using the Neko API, you can access the local filesystem, databases, network sockets&#8230; You can also easily extend its capabilities by writing your own DLL. &#8230; <a href="https://blog.sephiroth.it/2006/09/01/from-web-to-desktop/" class="more-link">Continue reading <span class="screen-reader-text">From Web to Desktop</span></a>]]></description>
										<content:encoded><![CDATA[<p>Yesterday   Screenweaver HX was announced as part of the haxe framework.<br />
With SWHX, you create an application by using two layers :</p>
<ul>
<li class="level1">
<div class="li"><strong>the System layer</strong> : written in haXe and using the Neko API, you can access the local filesystem, databases, network sockets&#8230; You can also easily extend its capabilities by writing your own DLL.</div>
</li>
<li class="level1">
<div class="li"><strong>the Flash layer</strong> : written in haXe or any other technology capable of producing SWF, you can use this layer to display the graphical interface, handle user interactions, play sound and video&#8230;</div>
</li>
</ul>
<p>Unfortunately I&#8217;m trying to install haxe/swhx on my Windows Vista but I&#8217;m not lucky at the moment 🙁</p>
<p>The second project is directly from <a title="adobe labs" href="http://labs.adobe.com" target="_blank">Adobe labs</a>, called <a title="Apollo on adobe labs" href="http://labs.adobe.com/wiki/index.php/Apollo:developerfaq" target="_blank"><strong>Apollo</strong></a> (flash, html, and pdf together), and currently it&#8217;s only a long description of what it can do and a list of F.A.Q., but Adobe says it will be pre-released on Adobe labs in the second half of 2006..</p>
<p>I&#8217;ve also found a <a title="Apollo overview" href="http://weblogs.macromedia.com/mc/archives/images/apollo2_thumb.jpg" target="_blank">diagram</a> which display makeup of an Apollo application.</p>
<p>Apollo is the code name for a cross-operating system runtime being developed by Adobe that allows developers to leverage their existing web development skills (Flash, Flex, HTML, JavaScript, Ajax) to build and deploy Rich Internet Applications (RIAs) to the desktop.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/09/01/from-web-to-desktop/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
