RIAs, Adobe Flex, and related topics

About
Resume
Contact

April 14, 2008

Time to switch to Ajax?

Filed under: Community, Flash, Flex — jimrobson @ 11:10 pm

One of the great advantages that Flash (and by extension Flex) has over Ajax is that you don’t have to worry about browser idiosyncrasies or versions: If your application heavily depends on JavaScript and/or CSS, you could find major issues whenever a new browser version comes out. By contrast, Flash 4 movies that I built 8 years ago still run in the Flash 9 player without issue.

However, that is no longer true for all developers or all applications. There is a significant difference in the way that the Flash 9 player handles swf’s that are loaded in at runtime. Grant Skinner details it thoroughly in this excellent blog post, but to put it succinctly: When you attempt to unload a dynamically loaded swf, the Flash player probably won’t release it from memory.

This issue has not affected me personally, because the applications I have built don’t typically unload swf’s. I make heavy use of lazy loading in order to improve application performance and load times, but I seldom unload a swf once it’s been loaded. The reason for this is a combination of bandwidth and user behavior: It is not unusual for a user to think that she has finished a certain task, only to discover a minute or two later that she needs to tweak something or re-do something. If I unload a swf when the user thinks she’s finished with it, then I need to chew up bandwidth re-loading it a minute or two later when she realizes her mistake.

But we don’t all build the same types of applications for the same user base. Some applications depend on the ability to unload dynamically loaded swf’s. If they can’t, then they experience serious memory issues. (See the replies to Grant Skinner’s post referenced above for some examples.) So this constitutes a dramatic change that requires these developers to do some heavy refactoring.

If Adobe is no longer going to maintain the same level of backward compatibility that Flash has historically enjoyed, then we lose one of our strongest reasons for using Flash. Of course, this is a bug, and not an intentional change. But how long will it be before it gets fixed, and how much pain is being inflicted in the mean time? And what happens if some future version of the Flash player has a bug that directly affects my applications? Can I trust Adobe to fix it promptly?

In the same post, Grant also points to the fact that AS3 handles dynamically loaded assets differently than AS1 and AS2 did. In AS3, you need to remove all references to everything in your dynamically loaded asset, or you can’t unload it from memory. It’s stuck there. I view this as a problem, as well.

In a very (un)helpful Flexcoders post on this topic, Alex Harui explains in that it is a great feature, because it prevents all of us idiots from writing the kind of “bad code” we wrote in AS1 and AS2. My thoughts on this? The Adobe team would do well to remember that they owe a large part of their success to us stupid, sloppy Flash and ColdFusion developers.

The technical merits of allowing us to unload assets without explicitly removing every internal and external reference are being well argued by others in the community, so I won’t repeat them here. However, I will say that if Adobe intentionally makes ActionScript development more difficult, then they effectively take away more advantages of Flash / Flex development: Ease of learning and time to market.

I’m not ready to throw in the towel yet, because I still see great potential in the future of Flash. However, I am concerned that Adobe is taking steps in a self-defeating direction. I hope I’m wrong.

2 Comments »

  1. Just to chime in on Jim’s post. I recently emailed him regarding my frustration on how much rigamarole I have to go thru to do what used to be utterly simple actions.

    For example button handling.

    AS1/2
    myButton.onRelease = function(parameters,,,){}

    Now try to do the same task in AS3. You have to create an eventListener, a custom event, and then tie everything together. What a nightmare - all in the name of the “good coding religion”.

    But is it good coding if one has to take 50x longer to write the code. And it’s actually both more cumbersome and less reusable than old code? One must conclude we’re moving in the wrong direction.

    Frankly, Java programming aspects have NOT impressed me. If all of this stuff is to be more like Java. Well, then I think we’re making a mistake personally.

    ***

    For example, all this discussion about the same difficulty I am having.
    http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=16663

    And really, all I want to do is something I’ve done for almost a decade.

    Click => myFunction(parameters, , , ,) => function myFunctionDefinition(parameters, , , ){}

    And somehow, we’ve advanced programming to where a simple task is now a convoluted nightmare. And this is a good thing?

    I really wish everything was just dot notation based.

    myButton.click=myFunction(,,,);

    And if I wanted to, I could simply store a value by saying.

    myButton.eggSize = large;

    And then myButton would automatically add “eggSize” as a container value. We used to do this in Flash with movieClips all the time. *shrug*.

    Stupid Java….has to go an make life difficult by everyone conforming to it. I bet you in 25 years programmers will laugh at Java the way they ridicule COBOL.

    Comment by Jason The Saj — April 16, 2008 @ 2:46 pm

  2. The ironic thing here is that much of the initial appeal of Java derived from the understanding that it was easier to learn and enabled faster time-to-market than other languages. With ActionScript 1 and 2 you could do more with less code than you could ever do with Java (of course you can do things with Java that you can’t with Flash, but that’s beside the point here). In terms of productivity and barriers to entry, ActionScript 3 does seem like a step backward. I sometimes wish that Adobe had used Ruby as a model rather than Java.

    From a business perspective, Adobe’s decisions make sense: they were going for the Enterprise market, which is full of Java/J2EE expertise, so making Flash development more like Java development (via AS3 and Flex) seemed like a great idea. After all, if you’re already a Java/J2EE developer, then Flex is very familiar and easy to learn.

    Comment by jimrobson — April 16, 2008 @ 10:31 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment


Powered by WordPress