<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>blog.joa-ebert.com - Blog of Joa Ebert</title>
	
	<link>http://blog.joa-ebert.com</link>
	<description>Actionscript3, Flash, Java, C#, C++, Algorithms &amp; Imageprocessing</description>
	<lastBuildDate>Sat, 06 Mar 2010 13:33:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/je2050" /><feedburner:info uri="je2050" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Compiling ActionScript In The Enterprise</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/AHRGF2kHgrk/</link>
		<comments>http://blog.joa-ebert.com/2010/03/06/compiling-actionscript-in-the-enterprise/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 13:29:16 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[asc]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[fdt]]></category>
		<category><![CDATA[fsch]]></category>
		<category><![CDATA[intellij idea]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=537</guid>
		<description><![CDATA[
			
				
			
		
If you ask me if ActionScript is ready for the enterprise then this question is hard to answer. Every fairly huge codebase requires some maintenance. You will have to figure out a strategy to identify modules and separate them. You will also have to handle the dependencies between modules. Last but not least you have [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F03%2F06%2Fcompiling-actionscript-in-the-enterprise%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F03%2F06%2Fcompiling-actionscript-in-the-enterprise%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>If you ask me if ActionScript is ready for the enterprise then this question is hard to answer. Every fairly huge codebase requires some maintenance. You will have to figure out a strategy to identify modules and separate them. You will also have to handle the dependencies between modules. Last but not least you have to compile those.</p>
<p>An important aspect is that when I am talking about modules  I am not talking about &#8220;Flex Modules&#8221; but the more generic term for a part of a project.</p>
<p>First of all you have to make sure to fulfill some requirements. You can not assume that every developer is working on the same platform using the same IDE with the same settings. But you must assume that your project will not be built from an IDE. You must also assure that the dependencies between projects are up to date across different platforms and IDEs. Once you have figured out how to do that you might want to think about a strategy to compile your modules.</p>
<p>Today I want to explore the idea of parallel compilation across a cluster of machines to yield optimal compile speed for ActionScript projects. First of all, you can not assume that a developer can always keep all modules up to date. Depending on the dependency graph of your projects compilation migh take very long. For instance we have 103 modules at Hobnox. This means we have 103 different compile targets with different dependencies, each yielding its own SWF/SWC file. We also have a &#8220;standard library&#8221; that is included in nearly every project. Changing this library will require the developer to recompile all 103 modules to update them.</p>
<p>To illustrate this example I want to explain what we went through.</p>
<ol>
<li>We used FDT to develop our project. Since FDT is Eclipse based every module was represented as a separate project with dependencies to other projects. FDT however compiles your project only once you launch it. And it does not do this automatically for your dependency graph. As a result you have to manually compile 103 modules in the correct order. This would not be the problem if FDT&#8217;s live error highlightning and code analysis would not work on a SWC basis. But since the actual source-code between projects is not analyzed we had to launch all 103 modules to propagate a possible error or change. This was for us the point when we had to make a switch.</li>
<li>Ant was our second idea to build our FDT projects automatically. However we had to keep module dependencies up to date in all the different Ant files because the FCSH requires that you include external libraries of a library also in a successor of another library. This means if A requires B and C requires A. Then C requires also B. So we had to keep 103 Ant targets up to date for each change.</li>
<li>A custom build. We started working with a custom build tool I have developed in Scala. This build tool was smart enough to figure out which modules have to be recompiled without launching the ActionScript compiler. It also figured out which projects could be compiled in parallel since the ActionScript compiler is written in a way that IO is not the only bottleneck. We had an enormous improvement in compile time and usability for the developer since module dependencies where handled automatically.</li>
<li>We switched from FDT to IntelliJ IDEA since it offered us more features that we needed. IntelliJ came also with a much better strategy to compile modules. Basically it had the feature we always missed for FDT to automatically include libraries and to compile modules in the correct order automatically. However the guys at JetBrains made a mistake by counting on FCSH. The short story is that FCSH is absolutely not capable of handling a large codebase. What happened to us was that when we started a build FCSH would take up as much memory as it could, getting much slower until it finally crashed. Then FCSH started from scratch, consumed the maximum amount of memory again and crashed. This happend until a project was finally compiled but took also more than 15 minutes for a single change we made. This was of course unacceptable. Fortunately JetBrains implemented a feature request from us into IntelliJ IDEA which comes close to our custom build. From now on projects are compiled in parallel without using FCSH and without asking launching the compiler if no change has been made. This way we are able to work again. However only if we compile just a short amount of all modules since the main bottleneck is still the compiler.</li>
<li>A continuous integration server was our last option. This is a custom build server and we are using it until today. After each SVN commit we are building the required modules and their dependencies now automatically on a dedicated server. A change in the standard library takes about four minutes to complete now on a quad core. But the good thing is that we have set our main project to exclude a lot of libraries. The custom build takes care of that and we are loading now modules from the server. That way we can still compile local and include libraries we frequently change. Other libraries are loaded from the server and included at runtime.</li>
</ol>
<p>So the question is if this is now the ultimate solution. A custom continuous integration server that takes more than 4 minutes to propagate a change after a SVN commit? I do not think so. And here comes Scala into the game again. There is a project available called <a href="http://code.google.com/p/swarm-dpl/" target="_blank" title="Swarm">Swarm</a>. It makes use of Scala&#8217;s support for serializable delimited continuations. This means you can pause the state of your current program, send it to a different node in your cluster and continue with the program on that machine. And Swarm makes this task extremely simple. So for now a new research project is to take advantage of this feature. We can basically have one master server like Hudson or TeamCity and write a plugin for it that makes use of Scala Swarm. Swarm could be based on nodes in the office, normal computers and maybe a couple of dedicated servers to compile modules in parallel on multiple nodes. Each node would have to keep the VCS up to date. That way we should be able to compile projects much quicker and have a much better workflow in a large codebase. Besides that if you work with a CI server than you could also have the task of code analysis using FlexPMD for instance done on another machine as well.</p>
<p>I am really looking forward to this project when I have some time to work on it. My goal is to develop a plug-in for <a href="http://www.jetbrains.com/teamcity/" target="_blank" title="TeamCity">TeamCity</a> that we will use internally first. I expect to reduce the time for a full rebuild from about 4min to something like 30sec. This would be a huge benefit. I also hope that we will be able to make that plug-in available to the public.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/03/06/compiling-actionscript-in-the-enterprise/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2010/03/06/compiling-actionscript-in-the-enterprise/</feedburner:origLink></item>
		<item>
		<title>The Advantage Of ActionScript</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/DjUZKa-AbAU/</link>
		<comments>http://blog.joa-ebert.com/2010/02/11/the-advantage-of-actionscript/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 11:40:24 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actor]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=530</guid>
		<description><![CDATA[
			
				
			
		
Despite the fact that ActionScript has a couple of major glitches and missconceptions I think there are also a couple of great key features that force you to write better applications due to the language design.
First of all we have to aknowledge that ActionScript has some great features. Those include implicit getters and setters or [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F02%2F11%2Fthe-advantage-of-actionscript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F02%2F11%2Fthe-advantage-of-actionscript%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Despite the fact that ActionScript has a couple of major glitches and missconceptions I think there are also a couple of great key features that force you to write better applications due to the language design.</p>
<p>First of all we have to aknowledge that ActionScript has some great features. Those include implicit getters and setters or method closures for instance. Java 7 will have method closures finally after a lot of argy-bargy about their complexity et cetera. ActionScript developers are used to method closures and are buddy-buddy with them since Flash 4 I think.</p>
<p>But what is the real advantage of ActionScript? Here are my thoughts.</p>
<ol>
<li>
<h4>Poor Performance</h4>
<p>Yes. We have been educated  to optimize the hell out of our code. We have been educated to think about our code and how it performs. We have been educated to be creative with our tools, to tinker around. I know that this is not something to be essentially proud of but it led to a lot of creative and astonishing experiments. If you would tell a Java programmer you are still developing object pools they will laugh at you for a good reason. This is where the poor performance is annoying but something is very important: the potential. Think with the mind of a carpetbagger. Shares on the stock-market that never have a downturn are less interesting because there is less profit potential. So why am I talking about this? It is quite simple: Flash has still a lot of potential for growth. Flash did not pass its zenith already like other virtual machines. This makes me very optimistic for the future. There is still so much potential for the growth in performance and I think that <a href="http://apparat.googlecode.com/" target="_blank">Apparat</a> has shown this as well.</li>
<li>
<h4>Forced Asynchronism</h4>
<p>ActionScript has no ability to perform blocking operations (despite of AIR). This makes every application responsive. If you load files from an external source like a URL your application will stay responsive because you have to add listeners that react on certain events. I know this is somtimes cumbersome but every good application should make use of asynchronous IO for instance. If people are lazy they will simply spawn a new thread to perform blocking operations which is also okay but less performant. Usually the simple example is a server where you would spawn a new thread for every client. This is the worst you can do and Java tackles this issue with its <a href="http://en.wikipedia.org/wiki/New_I/O" target="_blank">NIO</a>. However a lot of people do not make use of NIO because they think it is hard to use for common tasks.</li>
<li>
<h4>Events</h4>
<p>Events are a great way to achieve concurrency. Some people call this immutable message passing. If your events do not contain state or are immutable, you have a powerful system to tackle concurrency. Basically this is what the EventDispatcher is all about. You add listeners for certain messages to a dispatcher and then you react on a message when it is dispatched to you. Again we have been educated to use a system which forces us to write responsive applications that is not based on synchronization and locks like Java or C++. If Adobe decides to implement multithreading in the Flash Player I hope they will choose to implement the approach of Erlang which is all about immutable events and event dispatchers. The only difference is that Erlang programmers call them <a href="http://www.javaworld.com/javaworld/jw-02-2009/jw-02-actor-concurrency1.html" target="_blank">actors</a>.</li>
</ol>
<p>This post is not an ode to ActionScript. There are still major issues like the lack of parameterized types. But I do think that there is a lot of potential. We can grow with the language and we can tackle upcomming issues. Concurrency is one of them, limited resources on a mobile device are another one.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/02/11/the-advantage-of-actionscript/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2010/02/11/the-advantage-of-actionscript/</feedburner:origLink></item>
		<item>
		<title>Infinite Lies</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/jFlp5rds3P4/</link>
		<comments>http://blog.joa-ebert.com/2010/01/31/infinite-lies/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 21:25:22 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[lies]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=512</guid>
		<description><![CDATA[
			
				
			
		
What you have told us is rubbish. The &#8220;open web&#8221; is really an acronym for Apple&#8217;s cash cow supported on the back of a giant tortoise lie. But Steve Jobs said that Flash is responsible for most of the OS X crashes! You are very clever, young man, very clever. But it is lies all [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F01%2F31%2Finfinite-lies%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2010%2F01%2F31%2Finfinite-lies%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>What you have told us is rubbish. The &#8220;open web&#8221; is really an acronym for Apple&#8217;s cash cow supported on the back of a giant <del datetime="2010-01-31T21:17:02+00:00">tortoise</del> lie. <em>But Steve Jobs said that Flash is responsible for most of the OS X crashes!</em> You are very clever, young man, very clever. But it is lies all the way down.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/01/31/infinite-lies/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2010/01/31/infinite-lies/</feedburner:origLink></item>
		<item>
		<title>The Scalable Apparat</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/znv8nkJwjRo/</link>
		<comments>http://blog.joa-ebert.com/2009/12/03/the-scalable-apparat/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 10:38:09 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat scala java]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=507</guid>
		<description><![CDATA[
			
				
			
		
I am a big fan of Scala and used it for a couple of internal tools here at Hobnox. What I really like about Scala is the fun factor and the programming speed. That is the reason why I decided to port the whole Apparat framework from Java to Scala. 
This was not an easy [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F12%2F03%2Fthe-scalable-apparat%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F12%2F03%2Fthe-scalable-apparat%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I am a big fan of <a href="http://www.scala-lang.org/" title="Scala">Scala</a> and used it for a couple of internal tools here at <a href="http://www.hobnox.com/audiotool" title="Hobnox AudioTool">Hobnox</a>. What I really like about Scala is the fun factor and the programming speed. That is the reason why I decided to port the whole Apparat framework from Java to Scala. </p>
<p>This was not an easy decision since Apparat is a big project. However I have decided to rewrite Apparat because of the following reasons.</p>
<ol>
<li>Some parts of the framework are not well thought.</li>
<li>TAAS would have been hard to optimize.</li>
<li>This is my (n+1)-th iteration of implementing the ABC format. I think a lot of things can be simplified again.</li>
<li>Scala is an ideal language for Apparat&#8217;s tasks.</li>
</ol>
<p>The Scala <a href="http://code.google.com/p/apparat/source/browse/trunk/scala/apparat/src/apparat/" target="_blank" title="Apparat Source Code">source code</a> is already available on <a href="http://apparat.googlecode.com" title="Apparat on Google Code">Google Code</a>.</p>
<p>Commits will happen early and often. The <a href="http://code.google.com/p/apparat/source/browse/trunk/scala/apparat/src/apparat/?r=176" target="_blank">current revision</a> is able to parse Swf and Swc files. I have also implemented most of the SWF tags which have been part of the Java framework.</p>
<p>I could compare the <a href="http://code.google.com/p/apparat/source/browse/trunk/scala/apparat/src/apparat/swf/SwfInputStream.scala" target="_blank" title="SwfInputStream.scala">Scala</a> and <a href="http://code.google.com/p/apparat/source/browse/trunk/java/Apparat.Core/src/com/joa_ebert/apparat/swf/io/SwfInputStream.java" target="_blank" title="SwfInputStream.java">Java</a> source every day.  Everything is so concise now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/12/03/the-scalable-apparat/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/12/03/the-scalable-apparat/</feedburner:origLink></item>
		<item>
		<title>Polyglott Programming On The AVM2</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/XO7kfWUcTj0/</link>
		<comments>http://blog.joa-ebert.com/2009/11/16/polyglott-programming-on-the-avm2/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 10:49:19 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[polyglott]]></category>
		<category><![CDATA[taas]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=502</guid>
		<description><![CDATA[
			
				
			
		
Take some time and think about this tweet for a moment. It took me a while to realize that Joel Hooks is right. I was embaressed of myself. How could I forget about that? But I had also a big smile on my face at the same same time. Let me explain why.
The Java to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F11%2F16%2Fpolyglott-programming-on-the-avm2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F11%2F16%2Fpolyglott-programming-on-the-avm2%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Take some time and think about <a href="http://twitter.com/jhooks/status/5688660297" target="_blank" title="@jhooks on twitter">this tweet</a> for a moment. It took me a while to realize that Joel Hooks is right. I was embaressed of myself. How could I forget about that? But I had also a big smile on my face at the same same time. Let me explain why.</p>
<p>The Java to SWF compiler does not compile Java sourcecode but JVM bytecode to ActionScript bytecode. This means I do not have to teach my program the Java language. It only understands JVM bytecode. This seems like an akward decision on the one hand since working on the bytecode level implies lots of problems. But it turns out that this was a really cool decision on the other hand. &#8220;<i>Java</i> to SWF compiler&#8221; is maybe the wrong description. &#8220;<i>any language that compiles to JVM bytecode</i> to SWF compiler&#8221; is maybe better.</p>
<p>So what does any language mean? Here is a <a href="http://en.wikipedia.org/wiki/List_of_JVM_languages" target="_blank" title="List of JVM languages">list of JVM languages</a>. Now you feel maybe like I did after reading that tweet. And I am really looking forward to get <a href="http://www.scala-lang.org/" target="_blank" title="Scala Language">Scala</a> up and running.</p>
<p>Some problems still exist. Threading is one issue and I will basically have to do what Scott Peterson did for Alchemy. But reflections, annotations and method overloading have to be solved as well. Some glitches may exist even after figuring everything out. Stacktraces will look pretty weird. However I think this is a really cool project.</p>
<p><b>Update:</b> I forgot to mention something important. Java supports native code. This means you can build a library that works with OpenGL for instance. Those native methods can not be converted. There are also some other things that do not work. File access is just one of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/11/16/polyglott-programming-on-the-avm2/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/11/16/polyglott-programming-on-the-avm2/</feedburner:origLink></item>
		<item>
		<title>Getting Rid Of null</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/Gw4If8OiYuo/</link>
		<comments>http://blog.joa-ebert.com/2009/11/06/getting-rid-of-null/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 18:15:51 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[option]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=495</guid>
		<description><![CDATA[
			
				
			
		
A couple of weeks ago I started learning Scala. I can highly recommend it. The language has a lot of great approaches to multithreading and scalability. The reason why I like Scala is because it is so simple yet powerful.
Of course doing something at home influences work. I decided to write a build tool for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F11%2F06%2Fgetting-rid-of-null%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F11%2F06%2Fgetting-rid-of-null%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>A couple of weeks ago I started learning <a href="http://www.scala-lang.org/" target="_blank" title="Scala">Scala</a>. I can highly recommend it. The language has a lot of great approaches to multithreading and scalability. The reason why I like Scala is because it is so simple yet powerful.</p>
<p>Of course doing something at home influences work. I decided to write a build tool for the Hobnox AudioTool which is about 200 lines of Scala code. Cool thing is that this tool replaces a manually maintained Ant build and all project dependencies are always correct. Plus analyzing the dependencies in a more powerful way allows me to spawn the compiler in parallel. Building the AudioTool is now twice as fast and much more comfortable.</p>
<p>When learning a new programming language you also learn about new concepts. Functional languages in general have a different approach to nullable types. I know Scala is not the only one but let me introduce the concept in terms of ActionScript.</p>
<p>When you have a method that returns either a result or nothing: what do you do? Imagine you have some kind of service and a Dictionary of users. Requesting a user works by his unique id. The Dictionary is private to the class since you want to keep it read only.</p>
<p><code>
<pre>function getUser(id: String): User {
  return hasUser(id) ? users[id] : null;
}</pre>
<p></code></p>
<p>If I would now simply ask the service for an unknown user and do something like <code>if(getUser('xyz').isLoggedIn) { trace('Hooray'); }</code> I could probably and up with a null-reference error. No one checks for me if the user exists. So what else could we do? Write a lot of boilerplate code and prepend a check if the user is null or not each time we request one from the service. A much better approach in my opinion is to throw an error as early as possible. In this case we would rewrite the method to something like this:</p>
<p><code>
<pre>function getUser(id: String): User {
  if(hasUser(id)) return users[id];
  throw new NoSuchUserError(id);
}</pre>
<p></code></p>
<p>In this scenario we get informed about the error as early as possible. But we are stuck again. First of all ActionScript does not enforce you to catch possible exceptions. This means if you do not read the documentation of a method carefully or look into the source code of a method before calling it somewhere you will never know that it throws an exception. And what if we are actually in a scenario where we do not expect errors for non-existing objects? Think of the Dictionary object throwing each time an error when you access it and the result is null. How could I even check if an object exists in a Dictionary?</p>
<p><code>
<pre>try {
  dictionary[key];
  return true;
}
catch(noSuchElementError: NoSuchElementError) {
  return false;
}</pre>
<p></code></p>
<p>I guess you see that this can not be the solution to our problem. In a real world example you may deal with your own collection of objects instead of a Dictionary of course. So we have to get rid of exceptions and null for the optimal solution. Scala&#8217;s approach to this problem is the <a href="http://www.scala-lang.org/docu/files/api/scala/Option.html" target="_blank" title="Option type">Option</a> type. We always abuse <code>null</code> as a placeholder when we want to express that an element does not exist. The <code>Option</code> means that either <code>Some</code> or <code>None</code> result exists. Rewriting our <code>getUser</code> function using this approach would yield the following ActionScript code.</p>
<p><code>
<pre>function getUser(id: String): Option {
  return hasUser(id) ? new Some(user[id]) : new None();
}</pre>
<p></code></p>
<p>Why is this much better than the old approach? When calling the method you will always know that the method has only an optional result value. We get rid of the exception and <code>null</code> values. Our only problem at the moment is ActionScript. The result is now untyped. In an ideal world this method would be written as:</p>
<p><code>
<pre>function getUser(id: String): Option.&lt;User&gt; {
  return hasUser(id) ? new Some.&lt;User&gt;(user[id]) : new None.&lt;User&gt;();
}</pre>
<p></code></p>
<p>However we can still tackle this issue by implementing null-representations of our objects. Imagine the <code>User</code> class. You could rewrite the code to something like this.</p>
<p><code>
<pre>function getUser(id: String): IUser {
  return hasUser(id) ? user[id] : new NullUser();
}

final class NullUser implements IUser {
  public function get isLoggedIn(): Boolean { return false; }
  public function get name(): String { return 'null'; }
}</pre>
<p></code></p>
<p>And even if you are interested in null-reference errors you could rewrite your code to something like this:</p>
<p><code>
<pre>final class NullUser implements IUser {
  public function get isLoggedIn(): Boolean {
    CONFIG::ThrowNullReferenceErrors { throw new NullReferenceError(); }
    return false;
  }
  public function get name(): String {
    CONFIG:: ThrowNullReferenceErrors { throw new NullReferenceError(); }
    return 'null';
  }
}</pre>
<p></code></p>
<p>It is definitely a very different approach. A functional language like Scala allows you to deal much better with Options. But it makes sense to diferentiate between an uninitialized variable which is <code>null</code> and an optional result of a function. Unfortunately this is at the moment very painful with the lack of generics in ActionScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/11/06/getting-rid-of-null/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/11/06/getting-rid-of-null/</feedburner:origLink></item>
		<item>
		<title>TAAS As A Decompiler</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/xqRhhefpLK0/</link>
		<comments>http://blog.joa-ebert.com/2009/09/29/taas-as-a-decompiler/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 09:59:30 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[decompiler]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[taas]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=487</guid>
		<description><![CDATA[
			
				
			
		
The TAAS compiler is different from the ActionScript compiler since its input is not ActionScript source code but already compiled SWF or SWC files. Just like the haXe compiler can output AS3 instead of a SWF the TAAS compiler can do the same.
Now if you add one and one together you see that the TAAS [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F29%2Ftaas-as-a-decompiler%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F29%2Ftaas-as-a-decompiler%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The TAAS compiler is different from the ActionScript compiler since its input is not ActionScript source code but already compiled SWF or SWC files. Just like the <a href="http://www.haxe.org/" target="_blank">haXe</a> compiler <a href="http://haxe.org/doc/flash/as3gen" target="_blank">can output AS3</a> instead of a SWF the TAAS compiler can do the same.</p>
<p>Now if you add one and one together you see that the TAAS compiler can be used as a very strong decompiler. My own tests have shown that it will work flawlessly where other commercial decompilers output rubbish. Since the compiler behaves like the Flash Player it will &#8220;execute&#8221; the bytecode in order to parse it which means it has a very highlevel understanding of the structure inside the SWF.</p>
<p>The only question is now what to do with the source code. I wrote the decompiler for my session at FOTB to show much easier how the optimizations behave. It is also a great tool to debug errors. But should it be opened or not?</p>
<p>To take it one step further one might also be able to write an obfuscator using the TAAS compiler. In my opinion it would be cool to have a strong decompiler and obfuscator, both being open source. We might also add an option to protect SWFs from the decompiler by adding something to the SWF metadata for instance. Of course this is just a simple rule which could be removed by someone once the code is open. What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/29/taas-as-a-decompiler/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/29/taas-as-a-decompiler/</feedburner:origLink></item>
		<item>
		<title>FOTB Recordings</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/LUWii1jldbY/</link>
		<comments>http://blog.joa-ebert.com/2009/09/28/fotb-recordings/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 20:29:19 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=484</guid>
		<description><![CDATA[
			
				
			
		
The people from Powerflasher were kind enough to upload their recording of my FOTB session. I am sorry that the microphone stopped working at the end. But you might still be able to understand what I was talking about if you turn up the volume of your speakers.



Link: 

Link: 

The recording of the jam session [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Ffotb-recordings%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Ffotb-recordings%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The people from <a href="http://www.powerflasher.com/" target="_blank">Powerflasher</a> were kind enough to upload their recording of my FOTB session. I am sorry that the microphone stopped working at the end. But you might still be able to understand what I was talking about if you turn up the volume of your speakers.<br />
<span id="more-484"></span></p>
<div align="center">
<script type="text/javascript" src="http://de.sevenload.com/pl/admzN8j/400x258"></script>
<p>Link: <a href="http://de.sevenload.com/videos/admzN8j-Joa-Ebert-FOTB-Part-01"><img src="http://static.sevenload.com/img/sevenload.png" width="66" height="10" alt="Joa Ebert @ FOTB - Part 01" /></a></p>
<p><script type="text/javascript" src="http://de.sevenload.com/pl/Z4NlqkP/400x258"></script>
<p>Link: <a href="http://de.sevenload.com/videos/Z4NlqkP-Joa-Ebert-FOTB-Part-02"><img src="http://static.sevenload.com/img/sevenload.png" width="66" height="10" alt="Joa Ebert @ FOTB - Part 02" /></a></p>
</div>
<p>The recording of the jam session is also available.  I just want to note that I used the <a href="http://www.processing.org" target="_blank">processing</a> library inside Eclipse for the speedcoding. This time I also practiced at home unlike for other jam sessions. The visualizer was an homage to a <a href="http://www.youtube.com/watch?v=zCA79Du-WqY" target="_blank">table</a> designed by <a href="http://www.daftpunk.com/" target="_blank">Daft Punk</a> for <a href="http://www.habitat.net/" target="_blank">habitat</a>.</p>
<div align="center"><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6749871&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6749871&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/28/fotb-recordings/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/28/fotb-recordings/</feedburner:origLink></item>
		<item>
		<title>Compiling Java and C# to SWF</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/mrc3_tDeTps/</link>
		<comments>http://blog.joa-ebert.com/2009/09/28/compiling-java-and-c-to-swf/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 13:41:03 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[soot]]></category>
		<category><![CDATA[taas]]></category>
		<category><![CDATA[visualbasic]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=480</guid>
		<description><![CDATA[
			
				
			
		
At the end of my Leaving the Sandbox session I showed two projects I have been working on without telling anyone. The first was a compiler that could compile C# to SWF. The second was another compiling being able to compile Java to SWF. First of all I have to say that both tools are [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Fcompiling-java-and-c-to-swf%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Fcompiling-java-and-c-to-swf%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>At the end of my Leaving the Sandbox session I showed two projects I have been working on without telling anyone. The first was a compiler that could compile C# to SWF. The second was another compiling being able to compile Java to SWF. First of all I have to say that both tools are far from being finished. They are a so called proof-of-concept. For me it is enough to know that this is possible. I am also not sure if I will finish one of those tools.</p>
<p>So how does this work? Because I am now working on the AudioTool backend for our highly anticipated launch I had to switch to fulltime Java development. In order to understand the JVM better I started to search for the optimizations that the HotSpot VM performs and stumbled upon a framework called <a href="http://en.wikipedia.org/wiki/Soot_(computer_science)" target="_blank">Soot</a>. Voilà. Reading about Soot made me question why nobody is working on such a framework for ActionScript. Probably because universities see Flash just as a toy. For us developers being dependent on the Flash Platform it is of course more than that.</p>
<p>I will quickly explain what Soot does. It reads compiled Java <code>class</code> files and converts the machine code they contain into a three address code representaiton. This code is then heavily optimized. TAAS is basically doing the same. I also want to note that Soot is by far more complex and complete than TAAS right now. It would be megalomania saying that TAAS is Soot for ActionScript. But you get the idea. The one framework converts Java to three address code and the other framework converts ActionScript to three address code. Maybe it is possible to connect them.</p>
<p>This is what I did for the Java compiler. The whole pipeline looks like this:</p>
<ol>
<li>Compile Java sourcecode with the Java compiler of your choise</li>
<li>Use Soot to get the three address code representation of a compiled binary</li>
<li>Create TAAS expressions for the expressions that Soot uses</li>
<li>Connect the TAAS graph the same way the Soot graph is connected</li>
<li>Compile the TAAS graph to a SWF</li>
</ol>
<p>This is about it. There is some glue-code involved here and there and I did not implement all Java expressions yet. I did also not bother about threads. Basically one could do what Scott has done for Alchemy.  The cool thing is that we get highly optimized Java code because of the Java compiler and Soot. Then the TAAS compiler can run a second time after linking is done and perform platform specific optimizations like inlining and loop invariant code motion for certain expressions.</p>
<p>I already wrote a couple of classes and packed them in a SWC. Those mimic the behaviour of the Java classes like <code>java.lang.System</code> or <code>java.util.LinkedList</code>.  On the Java side I implemented the Flash classes like <code>flash.display.Sprite</code> and <code>flash.events.EventDispatcher</code>. The interesting part is that all the methods those classes contain are marked native which means they have no implementation since they are native to the Flash Player.<br />
This is also a great advantage. It is slow in Alchemy to call Flash methods and to communicate with Flash classes. The Java approach does not have this tradeoff. I also do not have to trigger the ActionScript compiler. The conversion form <code>class</code> to <code>swf</code> is entirely done using Soot and TAAS.</p>
<p>So far for the Java compiler. But in order to show a little bit more of the potential I wanted to have a C# compiler working as well. The great thing about advanced languages and a large community is that people have already built a lot of tools. It did not take too long to find an advanced framework that converts C# to Java. Actually this is not be the best approach. But I could not find the &#8220;Soot for C#&#8221; the evening before my FOTB session.</p>
<p>So I am using <a href="https://net2java.dev.java.net/">net2java</a> to convert .NET code like C# or VisualBasic to Java. That code is then compiled using the Java compiler and I am using Soot again to convert the code to TAAS without much stress.</p>
<p>For me the most important part is to know that it is possible to compile .NET source code and Java binaries to SWF. To complete those tools one just has to implement all the missing expressions and the standard Java library in Flash. Everything could also work the other way around. Compiling from TAAS to .NET, Silverlight and Java is another option.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/28/compiling-java-and-c-to-swf/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/28/compiling-java-and-c-to-swf/</feedburner:origLink></item>
		<item>
		<title>After The Sandbox</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/IHmFfus9ME8/</link>
		<comments>http://blog.joa-ebert.com/2009/09/28/after-the-sandbox/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 12:48:39 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[fotb09]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=477</guid>
		<description><![CDATA[
			
				
			
		
In 2006 I got invited to the FlashForum Conference in Düsseldorf, Germany. It was my very first Flash conference and my topic was AS3 code optimization. I have talked a lot about bitwise operators, lookup tables and other techniques to speed your code up.
Now about three years later I wanted to prepare a very special [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Fafter-the-sandbox%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F28%2Fafter-the-sandbox%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In 2006 I got invited to the <a href="http://www.flashforum.de/" target="_blank">FlashForum</a> Conference in Düsseldorf, Germany. It was my very first Flash conference and my topic was AS3 code optimization. I have talked a lot about bitwise operators, lookup tables and other techniques to speed your code up.<br />
Now about three years later I wanted to prepare a very special talk for FOTB and make a step forward by getting rid of old <a href="http://wiki.joa-ebert.com/" target="_blank">habits</a> and <a href="http://je2050.de/files/misc/as3opt.pdf" target="_blank">idioms</a>. </p>
<p>Before <a href="http://www.flashonthebeach.com/" target="_blank">FOTB</a> I was not sure if I can present <a href="http://apparat.googlecode.com" target="_blank">Apparat</a> at all. For me as an autodidact it is not always easy to solve certain issues. <a href="http://www.quasimondo.com/" target="_blank">Mario Klingemann</a> talked about <i>Magic Moments</i> in Brighton. I guess I had one after a long time of thinking and failing. I got really into the flow and everything became so clear. Stay tuned for more detailed posts on the technique behind the different compilers.</p>
<p><span id="more-477"></span></p>
<p>However this was a really special conference for me. The standing ovations made me completely happy and I was absolutely overwhelmed by the response. After all those sleepless nights it was a huge gift of appreciation for my work. I will definitely  never forget that moment and all I can say is thank you. If you spend so much time working on an opensource project this is really the best that can happen. “Leaving the Sandbox” came from a long background. The end of the session was a really emotional for me. Thank you John for inviting me.</p>
<div align="center">
<div style="width:425px;text-align:left" id="__ss_2042016"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=render-090922122545-phpapp02&#038;stripped_title=leaving-the-sandbox" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=render-090922122545-phpapp02&#038;stripped_title=leaving-the-sandbox" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/28/after-the-sandbox/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/28/after-the-sandbox/</feedburner:origLink></item>
		<item>
		<title>TAAS progress</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/FrbjrPIXruQ/</link>
		<comments>http://blog.joa-ebert.com/2009/09/07/taas-progress/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 14:50:07 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[taas]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=472</guid>
		<description><![CDATA[
			
				
			
		
I have developed some other optimizations during the past couple of days. Including strength reduction and optimizing tail recursive calls.
Strength reduction can already handle about 55 different cases at the moment. For instance it will convert code like if( x - 1 == 0 ) into if( x == 1 ). But it will also [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F07%2Ftaas-progress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F07%2Ftaas-progress%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I have developed some other optimizations during the past couple of days. Including <a href="http://en.wikipedia.org/wiki/Strength_reduction" target="_blank" title="Strength Reduction">strength reduction</a> and optimizing <a href="http://en.wikipedia.org/wiki/Tail_recursion" target="_blank" title="Tail Recursion">tail recursive</a> calls.</p>
<p>Strength reduction can already handle about 55 different cases at the moment. For instance it will convert code like <code>if( x - 1 == 0 )</code> into <code>if( x == 1 )</code>. But it will also remove expressions that other optimizations could introduce. <code>x + 0</code> is something that might occur during inline expansion. Or <code>x + Number.NaN</code> for example. </p>
<p>But I really like the tail recursive optimizations. TAAS can detect if a method needs to call itself or not. Take this code for example:<br />
<code>
<pre>private function sum( i: int, value: int ): int
{
	if( i == 0 )
	{
		return value;
	}

	return sum( i - 1, value + i );
}
</pre>
<p></code></p>
<p>You see that the last statement <code>sum( i - 1, value + i )</code> is tail recursive. This means we can replace the recursive call to <code>sum()</code> with a jump to the beginning of the method after changing the method parameters. The <code>sum()</code> method becomes converted to something like a simple while loop. This means also that one could have written code like this in the first place since this optimization applies only to methods that do not have to be recursive after all.</p>
<p>Knock yourself out with some examples:</p>
<ul>
<li><a href="http://www.joa-ebert.com/swfs/taas/b00" target="_blank">Before</a> / <a href="http://www.joa-ebert.com/swfs/taas/a00" target="_blank">After</a> (Inline)</li>
<li><a href="http://www.joa-ebert.com/swfs/taas/b01" target="_blank">Before</a> / <a href="http://www.joa-ebert.com/swfs/taas/a01" target="_blank">After</a> (Inline)</li>
<li><a href="http://www.joa-ebert.com/swfs/taas/b02" target="_blank">Before</a> / <a href="http://www.joa-ebert.com/swfs/taas/a02" target="_blank">After</a> (Tail recursion)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/07/taas-progress/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/07/taas-progress/</feedburner:origLink></item>
		<item>
		<title>Euro Invasion At MAX 2009</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/U9BFUY6AofM/</link>
		<comments>http://blog.joa-ebert.com/2009/09/03/euro-invasion-at-max-2009/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 20:18:24 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[influxis]]></category>
		<category><![CDATA[max]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=470</guid>
		<description><![CDATA[
			
				
			
		
Since the news has spread pretty quickly I want to shed some light on this as well. Influxis has invited a lot of European Flash developers to come to LA and attend Adobe MAX 2009. Those include Seb Lee Delisle, Ralph Hauwert, Mario Klingemann, Andre Michelle and me. I was absolutely overwhelmed when I heard [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F03%2Feuro-invasion-at-max-2009%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F03%2Feuro-invasion-at-max-2009%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Since the news has spread pretty quickly I want to shed some light on this as well. <a href="http://www.influxis.com/" target="_blank">Influxis</a> has <a href="http://labs.influxis.com/?p=504" target="_blank">invited</a> a lot of European Flash developers to come to LA and attend Adobe MAX 2009. Those include Seb Lee Delisle, Ralph Hauwert, Mario Klingemann, Andre Michelle and me. I was absolutely overwhelmed when I heard about that idea first. I really want to thank the whole Influxis team for making this possible. You guys definitly rock! But I would also like to thank Adobe for sponsoring MAX passes in order to get everyone invited.</p>
<p>Hopefully I will meet a lot of interesting people and Flash Player engineers. It will be my first MAX so I am really curious.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/03/euro-invasion-at-max-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/03/euro-invasion-at-max-2009/</feedburner:origLink></item>
		<item>
		<title>First results of TAAS</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/ta-Q7tvEWYs/</link>
		<comments>http://blog.joa-ebert.com/2009/09/01/first-results-of-taas/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 17:42:00 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[taas]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=463</guid>
		<description><![CDATA[
			
				
			
		

Finally I am able to present the first results of TAAS. It was a long way to get here. I was actually not sure at all if I will manage to show something at FOTB 09. Let me explain what happens here.
In the image is the original ActionScript code on the left. The ActionScript bytecode [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F01%2Ffirst-results-of-taas%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F09%2F01%2Ffirst-results-of-taas%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<div align="center"><a href="http://blog.joa-ebert.com/wp-content/images/taas_test.gif" target="_self" title="TAAS in action" rel="lightbox[463]"><img src="http://blog.joa-ebert.com/wp-content/images/taas_test_s.gif" width="420" height="187" alt="TAAS in action" border="0"/></a></div>
<p>Finally I am able to present the first results of <a href="http://apparat.googlecode.com/" target="_blank" title="apparat: TAAS">TAAS</a>. It was a long way to get here. I was actually not sure at all if I will manage to show something at <a href="http://www.flashonthebeach.com/" target="_blank" title="FOTB 09">FOTB 09</a>. Let me explain what happens here.</p>
<p>In the image is the original ActionScript code on the left. The ActionScript bytecode produced by the ASC is in the middle and the compiled TAAS version is on the right. You see that I am running a loop and call a method inside that loop. It would be nice to have small helper methods like this one inlined automatically. TAAS can do this for you now.</p>
<p>So how does this work? First of all an SWF file is parsed and the bytecode is extracted. This bytecode is transformed into a <a href="http://en.wikipedia.org/wiki/Control_flow_graph" target="_blank" title="Control flow graph">control flow graph</a>. This control flow graph is converted into a graph of TAAS expressions which a lot of benifits. The conversion step works like the Flash Player and kind of executes your code. The result is that all methods and local variables are typed if that is possible.</p>
<p>It is much easier to perform a lot of optimizations now. Like <a href="http://en.wikipedia.org/wiki/Inline_expansion" target="_blank" title="Inline Expansion">inline expansion</a>. In order to do that I can simply compile the method that is called to TAAS and connect the vertices together in the graph after some adjustments have been made. The inline expansion step will automatically inline methods when it thinks it is useful and possible. You can only inline methods that are private or final and make no use of reflections.</p>
<p>Inlined methods create a lot of overhead. Usually they contribute additional local variables and the code gets bigger. So one step after the inline expansion is to clean everything up again. In this example I can remove those registers thanks to <a href="http://en.wikipedia.org/wiki/Copy_propagation" title="Copy propagation" target="_blank">copy propagation</a> and <a href="http://en.wikipedia.org/wiki/Dead_code_elimination" target="_blank" title="Dead code elimination">dead code elimination</a>.<br />
And it gets even better. If you take a closer look at the example, the <code>calc</code> method expects two paramters that are of type <code>Number</code>. Therefore the original method uses an <code>Add</code> instruction. TAAS knows about the types and sees that it will pass two integers into this method. Since it makes no sense to convert from <code>int</code> to <code>Number</code> to <code>int</code> it stays with integer in this case.</p>
<p>So after inlining the method ends up with even less local variables. The original local variable <code>t1</code> is considered useless since it is only used one time. TAAS will put the code <code>getTimer()</code> at the position where <code>t1</code> has been used and we end up with a heavily optimized method. What I like the most is that I do not have to change the way I write my ActionScript code. All happens behind the scenes automatically.<br />
Some other optimizations are implicit. TAAS will use <code>AddInt</code> instead of <code>Add</code> if both operands are typed <code>int</code>. A <a href="http://code.google.com/p/apparat/wiki/TaasProposals" target="_blank" title="TAAS Proposals">FlowOptimizer</a> is also involved and will invert the if expression for the loop. This can reduce the number of required jumps in a method by 50%.</p>
<p>I know that the output is not perfect. But this is all a work in progress and really the first result that I can share. The SWFs speak for them self.</p>
<ul>
<li><a href="http://www.joa-ebert.com/swfs/taas/before" target="_blank" title="Before TAAS">Before</a></li>
<li><a href="http://www.joa-ebert.com/swfs/taas/after" target="_blank" title="After TAAS">After</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/09/01/first-results-of-taas/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/09/01/first-results-of-taas/</feedburner:origLink></item>
		<item>
		<title>UML generation using Dump</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/GMi1NxVZdLQ/</link>
		<comments>http://blog.joa-ebert.com/2009/08/20/uml-generation-using-dump/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 18:11:39 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[dump uml apparat]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=458</guid>
		<description><![CDATA[
			
				
			
		

Dump has now another cool feature: UML diagram generation. The UML diagram is exported in DOT format. I think this is a really cool feature because the graph is built by analyzing a SWF file and you get it for free. I will probably create a different tool to make full use of the UML [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F20%2Fuml-generation-using-dump%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F20%2Fuml-generation-using-dump%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<div align="center"><img src="http://blog.joa-ebert.com/wp-content/images/uml_playerglobal.gif" alt="playerglobal.abc UML" border="0"/></div>
<p>Dump has now another cool feature: UML diagram generation. The UML diagram is exported in DOT format. I think this is a really cool feature because the graph is built by analyzing a SWF file and you get it for free. I will probably create a different tool to make full use of the UML generation since you could link multiple files together for a complete coverage. Since Graphviz is not able to underline text I have choosen to use a dollar sign for static methods. You will also get proper parameter names if you compile your SWF file in debug mode.</p>
<p>This is an example UML diagram for the <code>playerglobal.swc</code>. In order to create it I took the <code>playerglobal.abc</code> from the Tamarin sources and the command was <code>java -jar dump.jar -input playerglobal.abc -uml</code>.</p>
<p>Here are two example representations but be careful. The PNG size is 30831&#215;6232 and might crash your browser. Chrome can display the PNG for me but is not able to show the SVG correct. Firefox displays the SVG very well. You can download the PNG and open it in IrfanView or Photoshop to be safe.</p>
<ul>
<li><a rel="none" href="http://blog.joa-ebert.com/wp-content/images/uml_playerglobal.png" target="_blank" rel="lightbox[458]">PNG</a></li>
<li><a rel="non" href="http://blog.joa-ebert.com/wp-content/images/uml_playerglobal.svg" target="_blank">SVG</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/08/20/uml-generation-using-dump/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/08/20/uml-generation-using-dump/</feedburner:origLink></item>
		<item>
		<title>Inheritance Graphs</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/iyyMafq-VFE/</link>
		<comments>http://blog.joa-ebert.com/2009/08/18/inheritance-graphs/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:30:13 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[dot]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[graphviz]]></category>
		<category><![CDATA[inheritance graph]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=445</guid>
		<description><![CDATA[
			
				
			
		
The Dump tool is now able to export an inheritance graph for a given ABC/SWC/SWF file. This is a very easy and nice way to look at the classes and their relationships. The small image shows the graph for one ABC file of the AudioTool. I think this it is pretty neat.
You will need a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F18%2Finheritance-graphs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F18%2Finheritance-graphs%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://blog.joa-ebert.com/wp-content/images/inheritanceGraph.jpg" alt="Inheritance Graph" border="0" style="float: right; padding-left: 3px"/>The <a href="http://blog.joa-ebert.com/2009/08/17/dump-disassembler/" target="_self" title="Dump">Dump</a> tool is now able to export an inheritance graph for a given ABC/SWC/SWF file. This is a very easy and nice way to look at the classes and their relationships. The small image shows the graph for one ABC file of the AudioTool. I think this it is pretty neat.</p>
<p>You will need a program like <a href="http://www.graphviz.org/" target="_blank" title="Graphviz">Graphviz</a> to visualize the exported <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank" title="DOT Language">DOT file</a>. If you want to export the inheritance graph you basically write<code>java -jar dump.jar -input file.swf -ig</code>. I think this shows a really cool feature of Apparat. It is also very easy to reverse engineer a UML diagram. I am not interested in such a feature but maybe someone else.</p>
<p><b>Update:</b> Here is a full-size example for the inheritance graph of the unfinished ImageProcessing library I am currently working on.</p>
<div align="center"><a rel="none" href="http://blog.joa-ebert.com/wp-content/images/ip_ig_b.gif" target="_blank" title="ImageProcessing Library Inheritance Graph" rel="lightbox[445]"><img src="http://blog.joa-ebert.com/wp-content/images/ip_ig_s.jpg" width="420" height="69" alt="ImageProcessing Library Inheritance Graph" border="0"/></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/08/18/inheritance-graphs/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/08/18/inheritance-graphs/</feedburner:origLink></item>
		<item>
		<title>Dump Disassembler</title>
		<link>http://feedproxy.google.com/~r/je2050/~3/DcO-nvut5dM/</link>
		<comments>http://blog.joa-ebert.com/2009/08/17/dump-disassembler/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 14:44:08 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[apparat dump]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=439</guid>
		<description><![CDATA[
			
				
			
		
A very important tool for SWF manipulation is a way to debug them and to have a look at the bytecode. Dump is a tool that does nothing else but listing all SWF Tags and ABC files the way Apparat represents them internally.
I know that there are a lot of other tools out there. swfdump [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F17%2Fdump-disassembler%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.joa-ebert.com%2F2009%2F08%2F17%2Fdump-disassembler%2F&amp;source=joa&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>A very important tool for SWF manipulation is a way to debug them and to have a look at the bytecode. Dump is a tool that does nothing else but listing all SWF Tags and ABC files the way Apparat represents them internally.</p>
<p>I know that there are a lot of other tools out there. <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/swfutils/src/java/flash/swf/tools/AbcPrinter.java" target="_blank" title="swfdump">swfdump</a> and <a href="http://hg.mozilla.org/tamarin-redux/file/b7e3811ee1ae/utils/abcdump.as" target="_blank" title="abcdump">abcdump</a> are great already. I have used swfdump from the Flex SDK before. But I dislike how they represent namespaces and the fact that not all properties are always shown. Dump is simple. It lists everything and uses the naming form the <a href="http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf" target="_blank">avm2overview.pdf</a>. </p>
<ul>
<li><a href="http://www.joa-ebert.com/files/zip/dump.zip" target="_blank" title="Dump">Download</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/08/17/dump-disassembler/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://blog.joa-ebert.com/2009/08/17/dump-disassembler/</feedburner:origLink></item>
	</channel>
</rss>
