Stop Coding!

The Unofficial Flex Compiler Blog

Posts Tagged ‘Flex Compiler API

What’s New in the latest HFCD Build (2010-09-18)?

In the past couple of months, I managed to fix a few issues and add some enhancements to HFCD. They are now in the latest HFCD build (2010-09-18). Let me briefly describe what they are:

Exclusion Filters

The default behavior of the HFCD plugin is to upload all of the files in a Flex project to HFCD. This obviously is not ideal because a lot of these files are unnecessary for Flex compilations. So now there is a “Exclusion Filters” preference panel under “HellFire Compiler”. You can specify files and directories that you don’t want to be transferred to HFCD there. The default value is “.svn”, which you all know, is a directory created by Subversion. You could add a few more, e.g. .settings, bin-release, etc.

Launch Server

In order to use HFCD, a developer must start HFCD from Terminal (Mac OSX) or Command Prompt (Windows) before he/she starts Flex/Flash Builder. This is one extra step that some developers would like to skip. They would like to see Flex/Flash Builder to launch HFCD automatically. Well, as you know, the HFCD installer automatically setups a launch configuration in Flex/Flash Builder:

The HFCD plugin could simply launch HFCD based on this launch configuration. So now there is a “Launch Server” preference panel under “HellFire Compiler”. You could specify the name of the launch configuration in this preference panel. The HFCD plugin will take care of starting HFCD when the workbench loads and shutting down HFCD when the workbench closes. If you don’t specify a launch configuration name in this preference panel, it’s okay… that means you prefer to launch HFCD manually.

New <property> Tags in Auto-generated build.xml

Developers can use the “Generate Apache Ant build.xml” function to generate build.xml for their workspaces. It’s great for using such build.xml in CI. The paths in build.xml come from the compiler and therefore they are all fully-qualified paths. Usually, before you can use the build.xml file in your CI environment, you need to fix the paths. But the paths are everywhere in build.xml… making it quite cumbersome to fix. Now, there are 3 new <property> tags (${fb.workspace.dir}, ${user.home} and ${flex.sdk.dir}) for three of the most common paths. Hope this consolidation helps.

Turn Off HFCD Background Build During Debugging

Some developers like to make code changes while debugging. As you know, code changes trigger HFCD background builds. If you’re debugging, the background builds might slow down debugging. Now, the HFCD plugin detects whether debugging is in progress and instructs HFCD not to run background builds after receiving code changes.

HFCD “References” View

The primary function of the Flex compiler is to generate SWF output. But there are so many things that the compiler knows about. For example, given a definition, the compiler knows about its dependencies and its references. The dependencies are not difficult for developers to figure out because one can pretty much see that in the import statement list. However, it’s quite challenging to manually and accurately locate all of the references given a definition. One could use Flash Builder’s “References –> Workspace” feature but it takes extremely long time to execute at times. Now there is a new HFCD “References” View.

You simply open a file (MXML or AS). Set the editor active and open the “References” view. The view would ask HFCD for the dependencies and references for the definitions in the active editor window.

HFCD “ABC” View

And of course the compiler knows the bytecode it generates for the classes in your projects. One way to learn ABC bytecode is to look at what the compiler generates for the code you write. Now with HFCD, if you highlight a few lines of your code in the active editor and open the HFCD “ABC” view, the HFCD plugin would ask HFCD to return the bytecode that corresponds to the code on the highlighted lines.

The screenshot below shows the bytecode for the AS code on line 1445-1451 in UIComponent.as.

The HFCD “ABC” view is work in progress (the output could be better though…).

Written by Clement Wong

September 19, 2010 at 11:28 pm

Adobe: You shouldn’t need to use an add-in to Flash Builder!

with 4 comments

Many of us on Twitter or following Jesse’s blog regularly should notice his dissatisfaction with Flash Builder in his most recent blog post. If you’re not aware of it, please click here.

I must say that most of us developers are objective about our views on the various Flex IDEs out there. Frankly, some of them are more religious than others. But that’s okay. Let’s just say we’re a bunch of people passionate about the technology we use everyday.

Of course you expect Adobe to respond. The Flash Builder PM chimed in. Everything he said sounded reasonable but I’m concerned about this point of view and I quote:

Firstly, and most importantly, we are making a commitment to invest in coding productivity features in every new release – we don’t believe that you should need to use an add-in to Flash Builder or an alternative tool in conjunction with Flash Builder to get a productive coding environment.

They don’t think you need to use an add-in or an alternative tool with Flash Builder for Flex development. I have to disagree with them here!

First and foremost, let’s be blunt about this – there is no Flash Builder without Eclipse! Eclipse’s highly extensible architecture allows developers around the world to add support for their popular development platforms (look at Java and C++). Adobe and Flex are direct beneficiaries of the Eclipse effort. Some people say Eclipse is crap, so Flash Builder is also crap. Well, I don’t agree and let’s just don’t go there.

However, the Flash Builder product team should realize that as a good citizen in the Eclipse development community, they should consider adding some openness to their IDE (and I already advocated that 2+ years ago in one of my posts about opening up the FB profiler). This makes common sense to me because if they can’t do certain things due to resource constraints, they should leave the door open and let 3rd-party developers do/improve that, e.g. add some extension points, make some API public, etc.

I’m fortunate that there is a stable and public API (the Flex Compiler API) that allows me to build an out-of-process Flex compiler (a.k.a. HFCD). I made sure everyone understood before I left Adobe that this compiler API must be backward compatible. So far so good, Flex/Flash Builder 2, 3 and 4 all use the same API to invoke the compiler. And very soon, FDT4 from Powerflasher will be out and their IDE will use the Flex Compiler API. That instantly makes HFCD compatible with FB3, FB4 and FDT4!

My point here is to make a direct rebuttal against the idea that Flash Builder customers should never need to use an add-in. HFCD is an add-in to Flash/Flex Builder and developers find it useful (check here)!

Written by Clement Wong

September 11, 2010 at 11:16 am

Guest Post: HFCD 4 Review

with 2 comments

Hello, my name is Jeremy Petersen.  I’m the Vice President of Technology at School Improvement Network, and I wanted to take a moment to write a review of my experiences with HFCD 4.

Let me start with a little background. The School Improvement Network  http://www.schoolimprovement.com provides the solutions, products, and services that help teachers and educators increase student achievement.  Our flag ship product is a large Adobe Flex application called PD 360.  PD 360 is an on-demand professional learning system for teachers and educators, with a series of tools built around a library of video segments.

PD 360 started out as a simple on demand video player application back with Flex 2.0 in the fall of 2006.  The application has followed the maturing of the Flex platform with a full Flex 3 rewrite, and is now in the process of a full Flex  4 rewrite.   Along with the obvious advances and growth inherited in keeping up with latest versions of Flex/Flash Builder, the application has also grown exponentially in complexity, size, and features.  In fact, our Flex 4 rewrite has a (insert expletive) 42 modules!  The project has also gone from a couple of developers that tinkered on it in their spare time to team comprising of 4 full time Flex engineers, and 2 full time ColdFusion engineers.

Let me start out by saying that we love Flex 4, but after making the switch from Flex 3 and having rearchitected our application from the ground up (enter the 42 modules), we definitely noticed a HUGE hit in compile times.  All of our engineers have very capable hardware (Corei7 etc).  But to even change the text on a single button in the application would result in a 4-5 minute compile time.  Talk about a drop in productivity.

Now, enter HFCD 4.  One of our engineers read about it on a blog and decided to try it out.  His results were too good to be true.  After waiting a couple of weeks to make sure he did not have any issues, the rest of the team changed over on 30 day trial licenses to test things out.  Remember that 4-5 minute compile time from before?  With HFCD 4 , making changes to a single module, that compile time is down to 4-5 seconds!  Granted changes to code that is linked in to multiple modules (say our controller etc) still take a couple of minutes to compile, but for most of the work our team is doing we are officially back in business of writing code and not reading blogs or firing up World of Warcraft in between every single run/ compile.

So it goes without saying that we love this product!  But my review does not stop here. I have one other thing to comment on.  The support of Clement Wong (HFCD creator).  Clement went above and beyond our expectations in support and answering questions.  For some reason my personal install had some issues (it ended up being Eclipse problems).  Clement not only helped me via email, but even offered to do a phone call to get me up and running.  In addition, he is very responsive to feature requests and suggestions.

HFCD comes with a free 30 day trial, so grab a copy and try it out.  You have nothing to lose and everything to gain!

FDT 4 Milestone 4 Live Broadcast

leave a comment »

The folks at Powerflasher are going to demo their latest Flex IDE, FDT4 M4 (milestone 4) today in a live broadcast. It looks like they have some good stuff brewing. I don’t know about you but I’m going to attend. Don’t miss it!

http://www.ustream.tv/channel/fdt4-m4-live-preview

Written by Clement Wong

August 12, 2010 at 9:11 am

HFCD zip Arhives for Ant Lovers

Some developers don’t use Flex Builder and wonder how they can use HFCD from the command line or with their favorite Flex IDEs.

I have just made some HFCD zip archives available:

http://bytecode-workshop.com/hfcd/3/download/hfcd_3.2.0_full.zip
http://bytecode-workshop.com/hfcd/3/download/hfcd_3.3.0_full.zip
http://bytecode-workshop.com/hfcd/3/download/hfcd_3.4.1_full.zip
http://bytecode-workshop.com/hfcd/3/download/hfcd_3.5.0_full.zip
http://bytecode-workshop.com/hfcd/4/download/hfcd_4.0.0_full.zip
http://bytecode-workshop.com/hfcd/4/download/hfcd_4.1.0_full.zip

You don’t have to download all of them… just pick the version that you intend to use.

Unzip the archive. You’ll find a build.xml inside. Edit ${flex.sdk.dir} to point to your corresponding Flex SDK installation directory. Run ant. After running build.xml, you should see the HFCD “client” directory and HFCD “server” directory.

You start HFCD by running server/bin/hfcd. If you want to use ant to call HFCD, use client/lib/hfcd-ant-tasks.jar. For more information on how to use the HFCD ant tasks, please check out the HFCD ant task language reference:

http://bytecode-workshop.com/hfcd/doc/HFCD-Ant-Task-Language-Reference.pdf

Some developers want to see Maven/Flexmojos support. I like that idea too and I’m going to investigate. Stay tuned.

Written by Clement Wong

July 21, 2010 at 10:00 am

HFCD For Flex 4.1 Now Available

Dear readers,

HFCD for Flex 4.1 is now available. Sorry for the delay. I thought it would take me a week or two to release it. But I wasted a little bit of time working on the wrong Flex SDK revision! Boo…

The good news is that there is no Flex Compiler API changes in Flex 4.1. However, there will be some new methods added to the API in the upcoming Flex 4.5.

I think the most notable fix in the compiler in 4.1 is SDK-25206. If you occasionally switch between airglobal.swc and playerglobal.swc in your Flex Builder workspace, you may run into this issue. But this is a good fix and helps build performance too.

http://bytecode-workshop.com/#section=downloads

It’s Time To Hit The Road!

with 2 comments

I’m going to present at the Flex User Group meetings in Toronto and Ottawa this month (2010/06) and in Washington DC next month (2010/07).

Title: In-depth look at the Flex compiler and HFCD

Agenda:

  1. Basic architecture of the Flex compiler
  2. Compiler extensibility
  3. Overview of the Flex compiler API
  4. HellFire Compiler Daemon(HFCD)

Toronto (June 10th, 2010): http://www.torontoflex.org/torontoflex/index.html

Ottawa (June 23rd, 2010): http://www.eventbrite.com/event/704014727

Washington DC (July 7th, 2010): http://www.dc-flex.org/index.cfm

If you don’t live there but want me to give a talk, please contact me or your Flex UG organizer.

See you there.

Written by Clement Wong

June 2, 2010 at 9:58 am

HFCD 4 Is Now Officially Available.

Hi, I’m pleased to announce that HFCD 4 is now officially available.

HFCD 4 for Flash Builder achieves better Flex (full and incremental) build performance than Flex 3 and Flex 4 by utilizing:

  1. all of the Flex 4 compiler performance improvements
  2. multicore processor technology
  3. techniques to build Flex apps in the background.

and allows builds to be distributed to multiple machines on a local network. The HFCD ant tasks also make it easy to integrate HFCD with custom build systems or popular build systems like Hudson CI, etc.

To learn more about HFCD, please visit http://bytecode-workshop.com/.

Those who purchased HFCD 3 before today will receive their FREE copies of HFCD 4. Sorry, this special offer ends today.

But don’t be disappointed. If you find a HFCD bug and file it and I can reproduce it, you will get a HFCD license for free. Click here for details. The offer ends by the end of this month (2010/04) but I’m going to extend it until further notice…

Download HFCD: http://bytecode-workshop.com

[2010/04/02] Stop Coding! Did you know…

leave a comment »

Stop Coding! Did you know that Flex incremental compiler performance  varies based on what you change in a class? (Of course! What am I smoking!?) In both Flex 3 and 4, when you make a code change in an ActionScript class, the incremental compilation invalidates the build data (CompilationUnit) for the class you touched and all of its subclasses (or boardly speaking, its dependents) and compile them again. However, if your code change does not involve API changes (e.g. additions or deletions of public functions or variables), the build data for the subclasses and dependent classes stay.

Let me use the HFCD output to illustrate this. It takes about 6.7s (CPU time) to do a full, clean compile of framework.swc.


[Fri Apr 02 10:35:38 EDT 2010] compile(framework.swc) result=1 time=6695
[Fri Apr 02 10:35:46 EDT 2010] link(framework.swc) size=2013668 time=483

Then I add a function, doSomethingMeaningless() in UIComponent.as. The function has an empty body.


public function doSomethingMeaningless():void
{
}

Since this is a public function so it definitely changes the public API of UIComponent.as. The rule says at least all of its subclasses (a lot!) must be invalidated and compiled again in the incremental compilation. Okay, it takes about 4.5s (CPU time) to incrementally compile framework.swc.


[Fri Apr 02 10:36:03 EDT 2010] compile(framework.swc) result=1 time=4463
[Fri Apr 02 10:36:10 EDT 2010] link(framework.swc) size=2013907 time=467

Now, add something to the function, e.g. a trace() statement.

public function doSomethingMeaningless():void
{
trace("do something meaningless");
}

Again, UIComponent should be invalidated in the next incremental compilation. However, there is no public API change. All of its subclasses and dependent classes stay. The result? It takes only 1s (CPU time) to incrementally compile.


[Fri Apr 02 10:36:20 EDT 2010] compile(framework.swc) result=1 time=1088
[Fri Apr 02 10:36:21 EDT 2010] link(framework.swc) size=2013972 time=467

Of course, if you add 10,000 lines of code into the function, that’s a different story!

Note that this rule applies to ActionScript classes only. There is no API signature checking for MXML components. Yes, I know it would be nice to have that for MXML components. But it’s a lot more complicated to achieve than doing that for AS classes. Plus, MXML components are rarely deep in some foundation class hierarchies.

So what does this mean to you? Well, this “API signature checking” strategy in incremental compilations should help improve the flow of your daily coding activities if you group your API changes in a single “Save All” and avoid mixing API changes and function body changes. I’d say that this is a “good-to-know”, but don’t plan meticulously a few steps ahead what you want to save. Your brain should focus on coding… 🙂

Now, Start Coding!

Written by Clement Wong

April 2, 2010 at 11:10 am

HFCD Weekly Update… Added Command-line Options

with one comment

It’s been a busy week. Many thanks to those who downloaded and tested last week and this week’s builds.

The fixes are mostly related to making HFCD more plug-n-play. But the main attraction this time is the newly-added command-line options. You can now configure HFCD when you launch it from the command line:

  1. -compiler-port HFCD compiler port number. The default value is 50207.
  2. -admin-port HFCD admin port number. The default value is 50208.
  3. -concurrency Tells HFCD the maximum number of concurrent builds allowed. The default is the number of processors available to JVM. You don’t set this greater than the number of available processors because that won’t help the build performance. You set this number smaller than the number of available processors so that you can leave some processors to do something else.
  4. -background-build-delay Tells HFCD to delay launching of background builds by this value after the last file transfer/update. The default value is 500 (milliseconds).
  5. -autosave-heap-ratio Tell HFCD to start saving build data to disk once the heap usage reaches this ratio. The default value is 0.2.
  6. -autosave-interval Tell HFCD to check VM heap usage at this time interval. The default value is 5000 (milliseconds).
  7. -file-dir Tells HFCD where to save the source/asset/library/config files transferred from Flex Builder. The default value is user.home/.hfcd/files.
  8. -cache-dir Tells HFCD where to save build data. The default value is user.home/.hfcd/caches.
  9. -help display the HFCD usage.

HFCD 3: http://stopcoding.org/hfcd/3/download

HFCD 4: http://stopcoding.org/hfcd/4/download

Happy Coding!

Written by Clement Wong

February 5, 2010 at 2:32 pm