I was talking with my boss tonite about a big project coming up. He was explaining that a client was thinking of building a new site in AS2. I was dismayed. After developing with AS3 for a while, I was doing some AS2 work and hating it. After AS1, AS2 was a godsend, but after AS3, AS2 is a huge pain in the ass.
He patiently explained to me that my personal likings were not the only factors to consider. There was a lot of AS2 code that could be re-used. AS3 developers were rare and expensive, and training takes time. Etc.
In truth, weighing all these factors is above my pay grade. He is probably right in this case. But, of course, that’s not what I said. Instead, I threw out that AS3 development is just faster.
Faster? Because of the event model? The display list? My boss didn’t quite believe me. He knew about the performance gains, but AS3 looked quite similar to AS2 to his coder’s eyes.
They do look similar, but because I’ve developed with both, I can say that whatever takes me 100 minutes in AS2 takes me 70 minutes in AS3.
Why? It mainly has to do with two very mundane factors: the compiler catching undefined variables (a.k.a. typos), and the player catching run-time errors. When I’m working in AS2, without these advantages, I have to compile every few lines. Otherwise you find yourself with a program that does not work and absolutely no frakking idea where it went wrong.
Unfortunately, the staccato interruptions of compile-compile-compile is like babysitting a small child. It prevents me from thinking clearly about programming logic. Developing with AS3, on the other hand, is like conversing with an adult. I can actually finish a continuous thought. I’ll often sketch out a whole structure in code, and even modify it once or twice, before compiling. Then I’ll spend a few minutes mechanically correcting the little mistakes–and bang, it works. Honestly, it still surprises me.
The structure of the language also helps me think clearly. To make AS2 sing, you have to keep a large number of hackish details at your finger tips: delegates, attachBitmap, MovieClip, etc. Mastering these hacks is not rocket science, but only when you move to AS3 do you realize how much of your mental RAM has been engorged by them.
AS3 is just simpler and more logical. Often I can skim a native package and guess what classes can be found within, or just instantiate an unfamiliar class and use auto-completion to locate the likeliest methods. I don’t have to keep the details in mind because the details follow from one another. As a result, I spend less time thinking about the language, and more time thinking about something much more interesting–solving problems.
It could be AS3 gives me an unsually large productivity boost because I’m not as detail-oriented as the average programmer, and an organized language compensates for my unorganized mind. But what about you? I’d love to tell my boss that other programmers are developing faster with AS3.
Tags: workflow · code · office15 Comments
15 responses so far ↓
I agree, AS3 is faster once you are are over the learning curve. Here’s a couple of my favorite time savers:
1) No need to use mx.utils.Delegate.
2) XML handing much quicker using E4x
3) Events and custom Events I feel are easier to work with.
I would definitely recommend any new project to be built with AS3. AS2 projects won’t be able to use added functionality like how Adobe just added ability to load mpeg. And AIR only uses AS3 so code usability could benefit you here.
I think programming AS3 “feels” slower at first because there is more overhead you have to deal with: writing classes for everything, declaring and checking variable types, setting up event listeners, etc. In AS2, it was much easier to get away with cutting corners. For quick and dirty projects, you could make the case that AS2 is the way to go, especially if you’re trying to leverage some existing code. But for anything that’s larger than a few 100 lines of code, you’re better off in AS3.
Another feature of AS3 that you didn’t mention is the debugger. Once you get comfortable using it, it’s a huge speed boost. I’ve found myself no longer using trace statements. I simply set a break point and drop into the debugger. From there, I can investigate all my variables, and can also see the function chain. The debugger can provide a huge boost to development speed. (And yes, AS2 had a debugger, but it was practically unusable.)
I think a lot of what you’re running into is the fact that your IDE sucks for development in AS2. Use something like FDT and developing in AS2 blows away development in AS3 simply because it’s a full featured IDE that totally rocks and has everything made for you.
My problem with as3 right now is that the event architecture is good, but what about passing variables through events. Is there a way to do that - similar to how we did delegates?
Flex builder compared to something like FDT is like night and day — FDT makes as2 feel like a professional app and I get things done in as2 about half the time it takes in as3, just because of the ide.
Ak, a great IDE makes all the difference. FDT was just too expensive for me at the time I was doing AS2 all the time.
To pass variables in an event:
//create a custom event
class myCustomEvent extends Event
{
protected var myType:String;
protected var myVar1:Type;
protected var myVar2:Type;
public function myCustomEvent (myVal1, myVal2)
{
super(myType)
myVar1=myVal1;
myVar2-myVal2;
}
//listen for this custom event
myEventDispatchingClass.addEventListener(”myType”, onHear);
//dispatch a custom event
eventDispatchingClass.dispatchEvent(new myCustomEvent(value1, value2))
//access your variables
protected function onHear(e:MyCustomEvent)
{
trace (e.myVar1);
trace (e.myVar2)
}
Matt, thanks for the tip. I guess I need to see how that works in for loops. I know there were some pretty interesting ways of doing it in as2. I’ve had to do some wild gyrations just to get it working in as3 it seems.
It seems like I have write a wrapper around every core as3 class in order to get variables passed back. It’s a bit of a pain.
AS3 makes hard things easier and easy things harder.
For rapid prototyping, I think AS2 still has the edge. The loose typing and “don’t need to declare a class for everything” mindset lends itself better to quick mockups. For larger projects, that’s where you see AS3 pulling ahead. I’ve found I’m much less likely to introduce bugs when rewriting features under AS3.
Did you try haXe[1] for faster development in Flash?
[1] - http://haxe.org
I try to convince clients to use AS3. Not only is it a pain in the but to go back to AS2 after you got used to AS3 as you said but also AS3 executes so much faster.
I’m using FDT 3 now and there is simply no better IDE for AS2/3 development.
haXe sounds interesting and there are some features (Enums yum!) that are missing in AS3 but it’s difficult to devote time to yet another language.
Right. AS3 is much faster to develop in than AS2. AS2 has a much less mature structure. Of course, the initial approach of Macromedia was not wrong. Things needed to be simple and done fast, but there’s a reason why complex API’s like DirectX, for example, matured the way they did. As ActionScript embraces more stronger programming methodologies Flash will be come faster and easier to work with and even more reliable.
[…] Interesting article on Faster development with AS3? […]
Ah, so true… Your post made me laugh and cry at the same time.
All those sleepless nights spent debugging as2 (thank God for XRay!). The amount of f*cking trial and error unbearable. it was close to the cross-browser battle guys that do xhtml/css have to fight - only harder! I mean, you have to program in language that doesn’t report errors…cmon! :)
We’ve come a long way from tellTarget. :)
By the way, for Delegate in AS3, read my post here:
http://www.pasz.com/blog/2007/03/function-proxy-for-actionscript-3.html
“is above my pay grade”
wow, dude, so much attitude
*unsubscribed*
I hear you pal. So far the only solution I found was murdering your boss. I am right now at a local internet cafe in the border with Mexico.
I am just kidding but sure I’ve dreamed about that.
You have to work more on your convincing skills, that’s all, maybe.
Cheers!