Flex versus ActionScript – the debate gets new life

September 6, 2011 | By

A few days ago, a reader commented on my blog post, “The Flex Team discusses the future of Flex” and brought up the frequent debate of Flex versus ActionScript. This subject has been debated many times since Flex was born, but lately it is becoming a hot topic again, especially with developers shifting their focus to mobile apps.

Developers need to know enough to use the right tool for the job at hand–and that holds true for any technology, not just Flex. Yes, some developers are using Flex for things that Flex should not be used for (this has always been the case). Flex is a framework that gives us components, a declarative language (MXML), a sophisticated event model, data binding, view management and many other useful, time-saving features. When you compile a Flex app, everything is converted to pure ActionScript as step one of the build process. Is this generated ActionScript optimized for every possible use case? Of course not. The Flex product managers and engineers put a lot of effort into prioritizing where to invest engineering time based on a wide array of use cases, but they obviously can’t optimize for every possible scenario. On the other hand, a ton of engineering hours have been invested in optimizing the Flex framework, and you should take advantage of this where possible rather than investing your own time in building custom ActionScript. It simply depends on your requirements.

So, when considering whether to build an app with the Flex framework or to build it in pure ActionScript, you are really making a decision between using prewritten/generated ActionScript that was created for a multitude of use cases or to write your own ActionScript that is specific to your specific use case. Of course, the latter is sometimes going to perform better because your code will be exactly what you need it to be, but it’s usually going to take you much longer to write your app.

You can take the quest for performance to the extreme. If you want the absolute best performance possible, write your app in machine code that targets a specific device and create a different version for each processor that your app will run on. The performance will be insane because every instruction will be specific to your app, but the development effort will take years! I realize that this is a crazy comparison, but again, we developers have to make some intelligent decisions when deciding what to use. Frameworks like Flex save us time, but they do have some costs in terms of performance. By the way, the same holds true for JavaScript. I recently wrote an application that utilized a lot of jQuery. jQuery saved me a TON of time, and thankfully in my app, the performance was adequate without me having to replace any of the jQuery functions with my own JavaScript. (If you search around, you’ll find people having the same debate on when to use jQuery versus straight JavaScript though).

We are seeing new life in the Flex versus ActionScript debate because of the recently released 4.5.x version of Flash Builder, which supports building Flex apps that target iOS, Android, and BlackBerry Tablet OS. All of us who have been building mobile apps are having to think about performance a lot more than usual because these devices have dramatically fewer resources than the modern desktop/laptop computers that we’ve been spoiled by. Suddenly we are worrying about every optimization and every byte of memory just like “back in the good ol’ days”. When performance is an issue, the choice to use a framework that trades performance for a shortened development process is not to be taken lightly, so the cost versus benefit analysis is key. However, it’s not an all or nothing proposition…

The guys at HD Interactive have written some great games that are in the Apple app store, Android Market, B&N Nook store, and other markets. The games include Kung Fu Battle Slots, Pyramix, MrMixit, Neptune, and more (their home page has all of the links so you can check them out). I have been super impressed by their app performance, so I sat down with them and looked at how they do it. The apps are indeed Flex apps and they take advantage of Flex views, the component model, and the event model. However, many of the animations, transitions, and effects were written in pure ActionScript that is specific for the game because they needed the best performance possible for the specific use case. For example, some of the effects and transitions in Flex are great for most apps, but they were not fast enough to handle the types of animations and the rich graphics that HD’s games demanded, so they made the smart decision to invest some extra time writing their own animation code. They even go to Flash Pro to build some of the animations because the tooling made more sense for a couple of specific items. They are masters at using the right tool for the job at hand. They utilize Flex where it saves them time, and they write specific ActionScript as needed.

Most of the apps I’m involved in are data-driven business apps, which are very well suited for Flex. Flex saves me a huge amount of time because the framework provides a lot of the building blocks that these apps typically require. For these apps, the decision to use Flex is a no-brainer. This is usually the case for enterprise apps. However, for other apps, the decision may not be as clear. Like many decisions we developers make, the answer is “IT DEPENDS”. :)

Filed in: ActionScript, Adobe Flex, Android, Flex on Mobile, iOS/iPhone/iPad | Tags: , , , ,

About the Author (Author Profile)

Greg is an Adobe Creative Cloud Evangelist based in Tampa, Florida

Comments (2)

  1. sunil

    Good Blog. I am about to embark on Flex adventure and had the same question on mind.

  2. It’s difficult to judge which is better because both have equal importance and it would be depend on functionality… Thank for posting articles. It’s useful..