Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving AS3 forward?

Hi I use AS3 quite a lot for work, but I come from a Java/C/C++ education and find the language quite restrictive.

There seems to be two fundamental camps in the AS3 world:

  • The non-technical creative camp who want to get things working without to much trouble and computer science forced on them
  • The Technical camp (possibly coming from a Java/C# etc education) who are interested in using Flex and are used to relatively complex features in a language (generics, method/operator overloading).

AS3 seems to frustrate both camps:

The primarily creative camp think AS3 is a lot more work than AS2 (and they are correct) and they don't see the point in moving, when the benefits are needed, but the complexity increase and learning curve is relatively quite steep.

The primarily technical camp find that AS3 is existing in some sort of limbo between Javascript and Java, and is only half implementing concepts.

I have my ideas of what I want technically, but I don't think that's the most important issue right now. As why would Adobe make AS3 more technical? It is not being adopted by a huge portion of it's original users.

So my question is how can Adobe, and the user community move AS3 forward, not only technically but as a complete tool, where all users will want to adopt it?

One of my ideas is that AS3 should look at how to become more script like again, but retain typing. Possibly through type inference like in Scala. And also to stop following Java's as if it's the pinnacle of language design, start thinking about the problems the typical users are trying to solve.

like image 686
BefittingTheorem Avatar asked Sep 04 '09 08:09

BefittingTheorem


2 Answers

i'm from the 2nd camp very much ... i did a lot of programming with pascal, later delphi and then java, but then i decided girls and guitars are much cooler ... when i stumbled upon FlashPlayer in 2006, i was fascinated by the possibilities offered and started coding again, with AS2 ... Flash 8 was more of an accident, when it came to coding, so i very quickly moved to MTASC and FlashDevelop and got to know the language very well ... from then on, i had the same struggles as anyone seriously using the FlashPlayer platform ... so here's my point of view:

AS2 vs. AS3

ok, the most important thing is: language != API ... the core AS3 language is most of what is at top level, as well as the following from flash.utils: getDefinitionByName and describeType, as well as Proxy, Dictionary and (arguably) ByteArray (anything else either interfaces with the FlashPlayer or can be built with the core language) ... in AS2 this was moreless all valid types for JSON-values (Boolean, Number, String, Array, Object) as well as Function, and ASSetPropFlags ... the link between the language AS3 and the flash player is small ... for example mod_actionscript is an attempt to use the Tamarin VM as an apache module, with a completely different API of course ...

comparing the core languages, there are differences ... in the end, i'd say AS2 was a much more powerful language than AS3 ... you could practically change the whole language at runtime, it was prototype oriented (which is a much more powerful feature than class based inheritance), allowed mixins, AOP, etc. ... AS2 had a very clear and radical language design ... very few people actually understand that ... AS2 suffered the same misunderstanging as JavaScript (which to me is the untyped and incompatibility-tortured brother of AS2) did ... most people liked it, because it is so permissive ... as PHP for example, which is (apart from its massive market penetration and easy installation) the main reason for its popularity ... but JS and AS are very high level, expressive and powerful languages, whereas PHP is more of a tool to dirtily hack together some stuff (this is not about PHP, i just needed another permissive language to compare too) ... the thing is, what most people use in AS2 (and JS) is the permissiveness ... i very rarely saw the use of prototype based, functional, aspect oriented or even proper object oriented programming in AS2 ... >here< i listed a set of really cool AS2 features, that are either badly or seldomly employed ...

AS3 is Adobe's move towards Java ... it is very strict, static, even at runtime, but performs really much better ... and it is very unforgiving, forcing you to get quite verbous ... describeType alows a really new level of introspection, Dictionary is a nice time saver, and Proxy is the supermutant version of AS2's Object::__resolve, making up a bit for all the flexibility that has been lost ...

speaking about the language, i think AS3 was actually a step backward ... in a time, when high level languages are gaining popularity exponentailly, and when Sun decided to create JavaFX Script, and many other dynamic languages get to run on the JVM and CLR, Adobe decided to create a new, more static version of AS2, and a VM that is good for executing it ... a bit paradox i think ...

when comparing APIs, there are up and down sides of both AS2 and AS3 FlashPlayer API ... the latter definitely is bigger ... when it comes to their intersection (display list, networking, XML handling), there are pros and cons for every solution ... many people are a bit upset, that all the good old callbacks are gone and replaced by the new event model ... seriously, if you use a proper IDE, there is no difference ... but the latter is much cleaner and much more powerful (anyone remember how one mouse-input callback completely shut down all children?) ... also, this is something, that does not really matter, because you can reimplement AS3 event model in AS2, and you can reimplement AS2 callback system in AS2, both in a couple of days ... in the end, i'd say AS3 has a fairly bigger and more powerful API and in case of need, you can wrap it up, to be less verbous ... so in the end, i'd really say the AS3 API is better ... there is really no point in oversimplifying it ...

the point why everyone is moaning is that it requires a drastical change ... until AS2 the language developed step by step, being almost 100% downward compatible to the previous version ... the consequence was, you needed to do a radical switch, instead of a slow transition ... to put it in clear words: going for AS3, meant throwing away anything, which repelled many people, especially designers, because porting code was feasible, but porting .flas really is close to impossible, at least oldschool ones, where code is distributed within countless movieclips ... but really it is not more difficult than AS2 ... it imposes a little more things, but it has quite more features, and adresses many problems, that really everyone has undergone when starting with previous actionscript versions ...

Nicolas Cannasse, the creator of Haxe, which was mentioned a few times, also posted some thoughts about this on his blog ... of course his presentation of Haxe as the alternative is a little biased ... but i think that is natural ... an important point of Haxe is actually to be an alternative to AS3, and Nicolas is both very eager and capable to provide one, although in the end he, as the main language designer, has his own ideas, where the language goes ... but let me talk about Haxe as an alternative (this may be partially redundand with Nicolas' post, but i'll just try to summarize my point of view)

Haxe as an alternative

I have yet to try Haxe, but it seems to to much of a jack of all trades to really replace AS3.

this is wrong ... Motion-Twin, where Nicolas works, works a lot with flash ... actually, Haxe generates much faster AVM2-bytecode, and unlike AS3, allows the use of alchemy opcodes, so in the end, Haxe allows you to write much more efficient solutions for AVM2 ... as a language, it is really much richer ... Nicolas' post points out, that unlike AS3, Haxe is an open-source language ... what this means in practice is, that it is up to you to join the community and make feature requests, or even to learn OCaml, and to contribute directly ... Philippe Elsass, one of the main authors of FlashDevelop also recently made a nice summary about Haxe... a little less positive, but giving a little overview ... it also links to a post of Nicolas presenting the strongest language features of MTypes, the internal working title for Haxe at MotionTwin, before it was released and open sourced ...

Haxe is much more expressive than AS3 is ... it has generics, typed first class functions, enums with parameters, to mention a few things not listed in the MTypes feature list ... the using keyword provides some overloading possibilities, but i don't really see why method overloading makes sense ... for future versions, multitypes are planned, which provide a similar functionality ... operator overloading has been discussed many times, and most probably will not be implemented, because it makes code exchange difficult ...

In the end, I believe, Haxe is a better language for AVM2 ... and it gets better and better ... more reasons to learn Haxe are provided by some community fellows in this stackoverflow question ...

The future of AS3

i think AS3 will not be driven forward too quickly ... Adobe has better things to do ... Adobe uses the FlashPlayer as a platform to deploy Flex apps ... these are written in MXML, which without a doubt as a very powerful declarative language, translated to AS3 ... this is why Adobe needs AS3 and AVM2 to be fast, but not really to be more expressive ... with thermo aka flash catalyst, designers will be excluded from actual coding process and everything will move to Flex, using all the Flex server solutions ...

i don't like Flex and sticking with AS3 is not an option for me ... Adobe is moving the flash platform towards the Java platform, and i don't appreciate it ... i always prefered flash to java because it is so lightweight, and ActionScript because it is so productive ... i was very exited about AS3's new features, but i finally decided to move on because it seems to me, that AS3 developement is starting to stagnate ...

in the end, it's up to you to choose your path ... right now it's MXML (and a bit of AS3) or Haxe ... or try writing some language that has an LLVM frontend and compile it to AVM2 using alchemy ... Objective-C might be a good idea ...

so whatever your choice ... good luck ...

p.s.: i think you shouldn't use the term "scripting" language, when you mean that it is high level, expressive and dynamic ... bash script is also a scripting language, but it really is nothing like Ruby, Scala or all the ECMA-dialects ...

like image 109
back2dos Avatar answered Sep 22 '22 08:09

back2dos


I tend to disagree since I quite like the language. One thing we need to realize is that some of the features that the technical crowd want are VM features and not language features (e.g. threading).

The language needs to be developer friendly and not artist friendly now. Flash has moved a long way from site-intros, vector cartoons, ad banners and simple games. Most often in my day-to-day work it is being used to build custom in-house applications. These have completely different constraints and necessitate the language features introduced in AS3 (e.g. namespaces, strong typing). I've worked on teams of 9+ developers. Javascript isn't meant to handle such large scale developments - which is why Google uses GWT to enable them to write Java code that compiles to Javascript.

There were certainly some features of ES4 that I was very excited about. For example generic functions (basically method overloading), parameterized types (basically generics), generators (using yield) and the let, type, like, unit and wrap keywords. I was and am disappointed it was killed in favour of the watered down ES3.1/ES5 spec (I believe this was more political than technical). I hope Adobe has the strength of vision needed to implement that spec as AS4.

like image 25
James Fassett Avatar answered Sep 23 '22 08:09

James Fassett