Initial thoughts on AS2Lib

I've just started looking through the open source AS2Lib project. My initial reactions are mixed. There is some work towards implementing basic reflection which I find interesting (I had implemented a similar method as part of the MooseDoc documentation system for AS1) but also certain additions that I find quite redundant. For example: Do we really need to implement the Iterator pattern in AS2?

It's understandable that someone coming from Java who wants to make AS2 feel more like Java would want an iterator since they are used quite frequently in Java to loop over collections. AS (and thus AS2) has a loop -- a construct that Java does *not* have (the latest version did get a rudimentary version of it but it is nowhere as powerful as the one in ActionScript.)

I am all for taking the best of what Java (and Smalltalk/Java-based design patterns in general) have to offer and implementing them in AS2 (as our Ariaware RIA Platform will attest to) but I am quite opposed to the idea of blindly implementing *every* Java pattern in ActionScript.

Let's not forget that AS and Java are very different beasts. As much as we put powder and rouge on ActionScript to make it appear class-based (ActionScript 2), it is at heart a prototype-based language -- and that has real advantages at times.

Contrary to what you may read elsewhere, class-based languages are not any more or less object-oriented than prototype-based ones. The term is *Object*-oriented programming for a reason. The defining characteristic is the use and interaction of objects not their templates. In fact, one may argue that classes are an external entity in a purely object-oriented approach and one would be right. To contrast, prototype-based languages deal only in objects.

That is not to say that class-based languages don't have their advantages. Those advantages mainly stem from removing much of the rope that prototype-based (or object-based) languages give you to hang yourself with. In a large-scale development environment the flexibility of the development language is not the main concern, with other factors such as maintainability and scalability playing a much more important role. It is because of this that we use AS2 in our projects at Ariaware.

Also remember that ActionScript is a *scripting* language and "scripting" -- although others may tell you otherwise -- is *not* a dirty word. Programming languages such as Java and scripting languages like ActionScript are both tools. They both have a place. They exist because they are useful and fill a need. They continue to exist as long as they are useful and the most useful for any given task usually become the most popular. There is a reason Java failed as a client-side technology for web applications and Flash did not. Yes, learn from Java but please don't try to implement Java in AS2 and thereby add unnecessary bloat to your applications. The web is still a low-bandwidth medium for most users and, as Macromedia will tell you with regard to the Flash Player, every byte is valuable!

I hope this doesn't come across as a scathing critique of AS2Lib because that is not what is intended. I've only had time to perform a cursory glance around the packages and this entry has focused on a single issue that happened to catch my eye. Quite the contrary, it's great to see an active open-source effort along these lines in the Flash community (though I would have preferred it had the code been released under an MIT/BSD-style license.)

I plan to continue to look into the library and hopefully will have more thoughts to share on it in the future.