Thursday, April 2, 2009

Do I have to learn Actionscript 3? Is AS1 outdated?

Actionscript...1,2,3...they're all good! A biased opinion piece from an old hand at flash.

Executive Summary for CEO types:

Actionscript 3 is a good move if your company is large, well funded, and well staffed with low staff turnover. You have a good chunk of your budget put aside for R&D, and another good chunk for training and employee personal development, and process is important. Also customers don;t dictate how to run your company or what you are selling. They just trust you and depend on you to provide them with results and profit.

Actionscript 1/2 are great if you are effectively building your airplane at 30,000 feet or in startup/recovery mode. You constantly have to spin on a dime, retool overnight, and have relatively high staff turnover (staff last less than 5 years on average) and havent really settled into exactly what it is you do. You will make whatever the customer wants and on their schedule. The flexibility and lack of strictness in AS1/2 lend themselves perfectly to this, as well as the short learning curve for new incoming staff.

The essential differences


First of all, AS3 and AS1, while similar in appearance, represent two distinct virtual machines in the flash player. They are about as different as Java, C++, and Pascal are from each other. In fact, to send messages from a VM2 (virtual machine 2 / actionscript 3) to a VM1, you have to invoke the same communication as you would between the flash player and the containing HTML page, or java object or whatever. Suffice it to say, even within the code the two are strange bedfellows sharing the same containing plugin.


History
Actionscript 3 came about because Flash/Adobe are trying to compete with Microsoft and other "big" language platforms so they had to tighten up the rules to play in that space. They did a great job, but, in many ways, they lost the original appeal of flash as a kind of coding "sketchpad" where you could rapidly deploy prototypes, games, and interactivities for one off purposes.


Disadvantages of AS3 (from a business and practical perspective)

First, my personal perspective as a coder...
I have built apps in both languages with equal sophistication. As a coder, I find AS3 far more elegant and fun to work with, its less of a Kludge, and truly object oriented. I really, really like working in it, and I think as I coder I am more useful and "hire-able" being proficient in both.

In the following I will point out the potential pitfalls and objections to moving to Actionscript 3, but only to ensure companies move to the new technology without any misconceptions about the costs and real benefits.

Procedures and Housekeeping

AS3 requires a far stricter process, naming convention, and organizational set of rules and processes to work beyond 1 coder. There is no room for any flexibility in naming conventions, file hierarchy, or even root script file locations. File management is very complicated and requires a lot of housekeeping to keep everything straight. The end result is a cleaner, more scalable and robust product for sure, but if the project is under 2000 lines of code total, the housekeeping can easily outweigh the actual coding in terms of time and resources.

Comparatively, AS1 / Flash is relatively flexible. If a particular bit of code works, but maybe is inelegant or quickly written, the compiler will pass it. in AS3, the compiler is extremely unforgiving so a lot of time is spent finding "bugs" that aren't causing actual problems, but just represent inelegant wording or phrasing according to the compiler. (this is a highly simplified approximation of what is going on...but accurate nonetheless)

In fact, the language is now so complicated, that they had to invent another language called 'flex' that sits on top of it along with a lot of paint by numbers style components, in an attempt to simplify it to decrease the learning curve. Why build an entire set of classes, folders, and establish naming conventions when all you want is a silly banner ad that lets you click a golf club and hit a golf ball into a little hole...?

The converse of this of course is, if you are sufficiently able to reorganize your production team to handle the rigors of AS3, you will be more scaleable and capable as an organization, and ultimately your software will be more robust, and less dependent on one individual's idea of organizing things. This is an expensive thing to affect, can be worth while, and if your company isnt thinking about making software as part of its overall business model, well, thats like being any company that plans to deliver its product with no control over a key part of its supply chain. In short, scalability and process in software development is everyones problem, even if you make concrete tubes.

Stability
VM1 is fast, does most things you need in a production, has 12 years of evolution and bullet proofing behind it, and the VM2 still hasn't proven itself as truly faster than VM1 in all applications...actually in any.

I have also yet to find any instance where the VM2 actually outperforms the VM1 at least from the end user perspective. Certainly the VM2 is faster but the AS3 language demands it has to be. VM2 is, in this way, a bit like Windows Vista. The computers are faster, but the mundane tasks have actually seemed to become much slower because of all the overhead associated with a truly object oriented language.

I don't have any actual VM 1 vs VM 2 developer content statistics to quote, but I'm willing to wager that 90% of the interactive flash content out there is VM1.

Conversely, the best practices required by developers and the stricter language acts like a micro manager whipping your developer work force into shape, which again promotes stability, scalability and reusable code.

Why 90%? Well first of all, I'm not talking about videos. I imagine that easily the statistic for flash video on the web is the other way around, 10% swf and 90% flv/h4. Im talking about interactive flash content, or its primary "raison d'etre". I say 90% because if it was 100% VM1 3 years ago before VM2 came along, my guess is most flash developers at the time tried AS3, couldn't figure out how the document class worked, then went back to flash mx and kept working...then got hit with the recession and said...screw CS..im just sticking with what I know 'cause I gotsta eat.

On the other hand, many developers also tried AS3 in the flash dev, hated it, then tried flex. Flex didn't offer much originally because of the lack of components. Now with a few more components, its more palatable, but any developer who is ultimately responsible for performance of their apps knows that becoming dependant on a plethora of components built by everyone and their dog can lead to a lot of customer support calls that go very bad.

The other choice, VM1, means that you can deploy apps on a tried and true platform quickly and without a lot of housekeeping so you can keep your consulting rate low and know that all the code out there is yours, so you can be responsible for it.

So what exactly can you do in VM2 that you cant do in VM1? Precious few things.


Cool, useful effects
As long as you are publishing in flash player 9 or higher, you have full support of all the filters and transitions offered in the CS Suite of tools. That means blur, drop shadow, transitions everything...all available to you in VM1, although you might have to write in actionscript 2.


Coding Elegance
Actionscript 2 is kind of a kludge compared to AS3, but if you are thinking future, you can write in AS2 in very close in form to AS3, almost indistinguishably in fact.


Neato 3d Components
There are quite a few components built in AS1, but some really interesting 3d ones built for AS3. This is a curious one. Neither VM is as good of a 3d rendering engine as the major ones out there, and Flash will probably always be many years behind the leading 3d rendering engines in terms of physics, ray tracing, procedurals etc...because getting flash to do 3d is like trying to make surgical tools out of bananas...honestly.



Sort of possible but why ?

I ask you to compare Papervision 3d's latest doo hicky to any of the top game titles of today, like Unreal, Half life, Portal, Fallout 3, Bioshock..etc. or even Second life, which is basically a kind of a "platform" sort of. Even Google earth kicks ass over anything 3d in flash, even with the "optimized player". Again, bananas for surgical instruments.

Standalone Applications

With AIR, now you can make desktop applications with installers that run as a standalone in flash! Well, heads up sparky. You've been able to do that with AS1 for many years using programs like Screenweaver. And you can build those without requiring the end user to run a pointless "installer". Just double click the icon and run the program when you want, and when you're not running it, its not pervasively existing in tiny pockets throughout your massive maze of folders in the mysterious c and d drives.

Speed Advantages
Since the VM2 player is, in fact, much faster than VM1 in terms of computations per second etc, you should be able to see marked improvements in high end math applications, working with a lot of children classes that exist and disappear rapidly to form various effects, and procedurals like smoke, water etc. Well, in reality, the VM2, while faster than VM1 for this kind of thing, is still years behind more optimizable code like C++, Java, and processor array specific languages that do the big number crunching that again, flash will never hold a candle to or be practical for. It is fun to play with this, but in the real world business app, not worth investing in the learning curve or the cost of the latest CS4.

Mobile devices and Social Networking apps
Since VM 1 is a smaller, simpler player that ran very well on very slow machines in years past, and netbook computers and cellphones seem to be taking us developers back to those 800mhz days and downgrades to windows XP on the rise in spite of Microsoft dropping support for it, all the new bells and whistles in AS3 may not end up being supportable on the mobile devices. Developers who become dependant on the new components because they couldn't learn to build their own will be stranded until the phones and netbooks can support them.

Even the most successful social networking apps are still very simple, and don't even begin to scratch the surface of what a developer can do in AS1 or 2, so the need for 3 is still a long way off, and at the bleeding edge, if Second Life or some other real 3d engine came into open social, well, the papervision guys would be cut off at the knees over night.

Competing technologies
Microsoft Silverlight, Google Android, and many others compete directly with Flex and Actionscript 3 as platform development tools.

That said, none of the competitors can fit exactly what VM1 does, because that is what flash originally was, and what made it so popular. A very shallow learning curve on a simple app "sketchpad" where you could add fairly decent code to a bunch of pretty good graphics without having to go too code-nerdy with classes and methods and all that weirdness, and could focus on the graphics, animations, and fun stuff. It is an invented niche that flash VM1 still owns. No one else can touch them or compete, and it accounts for 95% of the interactive web games out there still, and they all are running very solidly with no sign of slowing down. Stuff I built in '99 in flash still runs just fine on my vista PC. I never did any updates, never had to rewrite anything. So as a VM1 developer, you essentially have no competing technologies to contend with.

Developing countries
As developing countries come to the table with their massive numbers, developers who have only had access to older flash development environments and definitely cant afford to keep up with Adobe's latest and greatest corporate edicts will again continue pushing out VM1 content for many years to come, and have even less interest in joining the party ranks of Adobe's VM2 crowd.

Business Case and Cost
Even if their developers really want to move to AS3, for flash dependent business there is a heavy price to pay. Some businesses have invested in the VM 1 heavily (whether they realize it or not-many CEO's probably don't) and the cost of moving to VM2 in terms of staff training, turnover, upgrading machines, changing general production policy, etc. may keep them away from it indefinitely, particularly if there is no business case that is compelling enough for them to move over. Trying to explain to a CEO that a number after the letters VM is worth 300,000 in staff turnover and training and platform rebuilding just to keep up with the Joneses when, essentially, it "ain't broke" is a hard sell for any nerdforce.

Adobe itself
Since Adobe managed to come up with "vm2" in the first place, what is stopping them from suddenly creating a "VM3" that only supports "Actionscript 4" and so on. Even though it seems crazy, it is possible that Adobe's head is so far up their own butt that they would actually do this. AS3 is already 3 years old now, VM2 has been around for a while, and devices continue to evolve in strange and unpredictable ways. Adobe has not indicated this sort of plan, but I dont think anyone but the most naive would assume that VM2 is the last of the VM's.

Nevertheless, and I can't stress this enough, as a developer you SHOULD learn AS3, become very good at it as a matter of professional learning. Even if you end up doing most of your work in AS1 or 2, you will be a better coder if you learn 3, and learn it well. It is a lot of fun to work with, and if Adobe is really stupid, may be the only thing you can build for in 2-3 years.

But given the fact that AS1 content constitutes 90% or more of currently being made (not to mention the huge amount of content made over the past 15 years) flash interactive content out there, the idea of Adobe dropping VM1 from the player is extremely unlikely in the foreseeable or even long term future. As VM2 gets bloatier and bloatier with more and more components and add ons, VM1 will remain a small, tight and efficient player that continues to do what it does very well.

Thanks for reading, I hope it helped. Please add your comments and particularly your criticisms below. I cant learn if you dont tell me why Im wrong!

2 comments:

  1. Very interesting and practical point of view. I come from Java / Corporate Development environment, and learning about flex/actionscript recently. There is not a big learning curve here, because it is very similar to java.

    ReplyDelete
  2. thank you for sharing this profound inspection - things are much clearer for me now.

    ReplyDelete