Question

I have a client asking me "What are the pros and cons with upgrading from AS2/Flash to AS3/Flex?" He is having performance and maintainability issues with his app.

I sorta hate these questions because I just want to say "AS3/Flex is going to be faster and more maintainable," but I know I should be more specific than that. The application is close to 100,000 lines of code, poorly documented, and the UI seems to all be dynamically generated.

Obviously the migration from Flash/AS2 to Flex/AS3 will be expensive, but is it worth it to improve speed and maintainability? Does anyone know to what extent it will improve speed and maintainability? Is there anything you can't do in AS3 that you can in AS2? I would guess not. Are there really significant things you can do in AS3 that you can't in AS2?

I guess the second half of this question is how do I answer questions like these correctly when dealing with clients? Short of spending many many hours looking through the tens of thousands of lines of code, I'm not sure I can be very accurate.

Thanks!

Was it helpful?

Solution

Performance Since you have 100,000 lines of code, executing the code on a VM that is 10x faster (as adobe says) will definitely enhance performance. But how is the performance of the current app? if it's good enough, then you really shouldn't consider this pro.

Maintainability and Reusability If the current code base is hard to maintain and is not reusable then it needs refactoring, not rewriting in a new language. AS3 does encourage coding practices that helps in maintainability and reusability, but that doesn't mean you and your team will follow them. It is also possible that with AS3 you will end up with a code base that is hard to maintain. It is also possible to refactor your AS2 code in a maintainable and reusable manner.

New Technology I believe this is the only real pro here. Flex/AS3 is a new technology. It's a nice and clean one. A lot of people are strongly supporting it. Adobe is pushing everyone to switch from AS2 to AS3. It will become harder and harder to hire new AS2 developers. There will be less development tools that support AS2. And my guess you will have to make the switch sooner or later.

So, IMO, with all the pros and cons everyone listed here, you need to let your client understand that this has to be done sooner or later if you are going to keep updating the app regularly. And I think you shouldn't rush doing that.

OTHER TIPS

Wikipedia has a decent list of new features by Flash Player version:

http://en.wikipedia.org/wiki/Adobe_Flash_Player

Everything starting at version 9 is only available to AS3. Here are some highlights, including some additions of my own:

  • Support for Flex 2+ (version 4 is coming out early next year)
  • Support for Adobe AIR
  • Binary sockets
  • H264 / AAC support
  • 3-D transformations
  • New text layout engine
  • Hardware acceleration

Having written Flex applications that ran under FP8 (Flex 1.5) and FP9+ (Flex 2+) I can tell you that it's significantly faster. For a business application that people spend a lot of time in on a daily basis I think it can be a noticeable improvement that would reduce end-user hair pulling. There are performance metrics out there for low-level operations like string concatenation and array sorting but those metrics don't equate to the performance gains you'd see in a real world application. In reality, they will be smaller, but measurable.

Ultimately the best you can do is estimate to them the cost of maintaining the application as-is versus the rewrite and addition of subsequent features. If they don't plan on changing much in the application then the rewrite likely won't be worth it. But if the app is having a lot of features added and you feel you can be significantly more productive using Flex and AS3 then you should be able to show them the numbers and let them make the decision based on that.

The biggest and most important reason to upgrade is that as far as Adobe is concerned AS2 is a dead language. AS2 is run inside of it's own special VM (AVM1 to be precise) that dotters along with the rest of the Flash player forever stuck back in the world of Flash 8. No new features or optimizations will ever make their way back to AS2 - period.

In addition, if this application will live on for a long time it's important to understand that the amount of developers who know and understand AS2 is just going to diminish over time. If the jump to AS3 is going to happen with the application it would be easier (and probably cheaper) to do it sooner rather than later.

Other answers have covered the bases nicely, but I will just contribute that performance-wise, script execution for well-written AS3 tends to execute anywhere between 3 and 100 times faster in AS3 than AS2. It varies widely based on what's being done. Note, however, that for most applications performance problems are not wholly or even primarily due to script execution. Usually rendering is the biggest bottleneck, in which case switching to the new AS3 VM may yield moderate benefits, or possibly even none at all. Only profiling can tell whether your particular application will see significant performance improvements or not.

But that's just to fill out the discussion. I agree with other commenters that the biggest issue is that many new features only work in the new VM. Remember that it's not just a question of switching languages - the Flash player currently has two different virtual machines in it, and the AS2 VM is essentially a legacy application now.

One other thing others haven't covered - interoperability between AS2 and AS3 content is very poor. If you are likely to be loading in outside content (SWFs), or trying to use 3rd-party libraries (graphing components, or things like that), you'll likely see that most such content is already AS3, and AS2 stuff will only get rarer.

AS3 is superior to AS2- plenty of reasons above, including VM performance, stricter compiler for enforcing cleaner coding practice (strict typing, etc). I didn't see anyone mention that you can change an object's parent object at runtime in AS3, something you could not do in AS2, and if you ran into this issue you know what a road block disappointment that is.

But, more importantly when you code things in AS3, THEY WORK AS THEY'RE SUPPOSED TO. None of this quirky AS2 stuff where you discover bugs, shortcomings, and just strange results from code limitations on a fairly regular basis!

If you're considering porting / rewriting, you should also consider any learning curve you might have to wait for if your dev team is experienced with AS2 but not AS3.

With a 100,000 line codebase (which is pretty huge by any actionscript standard), porting is going to be a nightmare unless the code is documented, elegant and organized. You might find that re-writing from scratch by starting with building a more efficient and organized framework / design pattern for the app cuts the size of the codebase in the end significantly... maybe it only needs to be a 50,000 line codebase if it's done right?

good luck!

I personally could never stomach AS2 and avoided the language entirely before 3. There are a lot of reasons already posted by others, but here is a quick list off the top of my head:

  • It is easier to create reusable code
  • You can follow production tested best practices
  • access to solid micro-architecture frameworks (Robotlegs, Swiz, PureMVC, Mate, Parsley, et al)
  • Increased speed
  • Not stuck with just Flash or Just Flex, access to both component libraries
  • take advantage of new player features
  • access to the loads of libraries that as3 has brought to the scene
  • ability to use upcoming tech like Flash Catalyst
  • Robust IDE that improves efficiency and ability to work with larger teams
  • Not tied to the f'n timeline.

To me the choice isn't Flash/AS2 and Flex/AS3 - you don't lose Flash... at all. You only gain, Flash, Flex, and pure AS3.

I would suggest that porting a 100,000 line application from AS2 to AS3 is really little different to a complete rebuild from scratch, considering the amount time it would take. What you'll find is that many of those 100,000 lines may not even be needed. And if the code includes any kinds of frameworks etc I would be even more worried, as you may have to port these yourself, at which point you might as well have just started again. Your client needs to think about how long they want this project to live. If it's less than a few years, I say don't bother. If this app is their whole business, I say time for version 2.0, and while you're rewriting features in AS3 take the time to improve the functionality and usability of the app.

AS3 is not better than AS2

i don't quite get this whole AS2-bashing thing ... i know only very few people who actually seem to understand the great possibilies of AS2 ... AS2 can be compared to Ruby, whereas AS3 is just where Java was 10 years ago ... yes it's slow, but it is much more powerful and expressive than AS3 ... i don't know about any fundamental feature AS3 has and AS2 hasn't (don't confuse language and API), except proper error handling ... on a moreless related topic, i got in to details recently ... AS3 has access to a much bigger API, but most of the important things are nothing you seriously need in business app ...

AS2 can be highly productive and elegant, if you actually use it to its full extent ... if you want to have the same flexibility in AS3 as in AS2 (or the best approximation you can get, at least), you will find that most of your code execution speedup goes out the window ...

Do not use AS3

i am serious ... if you want to target the AVM2, use either Flex through MXML with least possible ammounts of AS3, or Haxe ... use Flex if fast developement is important to you, and Haxe if it's more about performance (well, there are other reasons to do so, but they are more subjective i guess) ...

until today AS3 has been a dead end ... the language has not been changed a bit since it was introduced ... sure, the flashplayer has new features, but AS3 stayed AS3 since its release 3 years ago, except for Vector, which is just some quite faky thing ... you may want to note that it took 3 years from AS1 to AS2 and another 3 from AS2 to AS3 ... and it's really time for an AS4, but Adobe does not seem to work on anything like that ... instead they focus on expanding their product palette more and more ...

What should you do?

subtextually i got the impression, that you have some 100000 lines of spaghetti code ... so the actual problem is the code, not the language ... you need to do a rewrite ... if you think it makes sense, you can even rewrite it in AS2 (although still i'd suggest the use of Haxe instead) ... the only point in actually using AS2 is that you could copy and paste some implementations, if you are lucky ... but you really should just build a clean app from scratch, using the best of what the language you use provides, being a subset of OOP, AOP and FP (Haxe/AVM1 would allow all of these things) or a declarative approach, as allowed by MXML ...

except for the obvious problem, which is cost, there is no con for a rewrite ... the pro is you winding up with a better code base, that is more maintainable, flexible and probably even performs better, or at least it makes profiling and later optimizing easier ... the expressiveness of a language is a factor, when it comes to writing good code, simply because developers are lazy, but other than that, it has no impact on anything but performance and productivity ...

When it comes to clients ...

... i'd suggest you tell them the simple truth: they can have a software that provides a fixed set of functionality at the least price possible (which is probably what they have right now, in your case), or they can have flexible/extensible/well designed software ... and even if they choose the latter, they will have to accept, that every once in a while you need to take drastic step, such as rewrites ... constant degradation of code is an undeniable phenomenon ... when you design a software, you start making decision in which directions it can evolve in in which it can't and you will come a point, where the obscure web of dirty hacks added to implement functionality, which the software was not layed out for, will make any further extensions uneconomical ... do not hesitate to point out to your clients, when a software you are to extend (be it yours or not), that it's a very good point for a rewrite, instead of letting them pay for all the inefficient work needed to add the extra functionality they need ... the cost for software extensions grows exponantially ... after a rewrite, this cost gets back that "close-to-0-shallow-part" ... it's up to your own expertise to determine, at which point it makes more sense to do a rewrite (if looking through 100K lines of code is necessary just to actually do this assessment, it's clearly a good time for a rewrite in my opinion) ... get a picture of what you think where the software should go, what is needed for that, and choose the most efficient way to do so ...

I would scale the hardware before looking at upgrading the application code base (especially if you think it will be difficult to upgrade). It will be both quicker and cheaper to scale the hardware.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top