tags:

views:

559

answers:

11

Is ActionScript a scripting language or is it more an object-oriented programming language like Java? A quick check on Wikipedia lists it among scripting languages...

A: 

I think it might depend on what version you are asking about. I am not an actionscript expert, but it looks like the designers are trying to make it an object oriented language. I think with 3.0 they have effectively made the jump (at least partially) to an object oriented language.

Kevin
+3  A: 

Although it is called Action"Script" it is an Object Oriented Language very Java-like. All code gets compiled into a binary swf file.

  • ActionScript 1 also was OO based on prototypes.

  • ActionScript 2 adds classes, accessors, etc but this is pretty much syntactic sugar on top of AS1.

  • ActionScript 3 is completely redesigned and runs in a new virtual machine (AVM2) inside the Flash Player in parallel with the old virtual machine.

Christophe Herreman
So? Many other languages get compiled to byte-code too. Some even get JIT compilers, and they are generally grouped as scripting languages. Python already has two. PHP can also be byte-compiled, as can Perl. Very few scripting languages actually use an interpreter, most that I know of compile.
Devin Jeanpierre
The previous comment is made partially obsolete by the edit, but "script" remains in scare quotes.
Devin Jeanpierre
ActionScript is a Scripting language. Scripting is not programming. ActionScript is somewhat unstructured. It has gotten better but I still see plenty of room for improvement.
Devtron
+2  A: 

It's a variant of EcmaScript, so it's akin to JavaScript.

ActionScript

toast
+1  A: 

AS 3.0 can be written as OO. Previous versions are more JavaScript like and procedural.

lynn
As other posters have posted JavaScript (and thus AS < 3.0) are very much capable of OO-style. It's just not class-based.
Joachim Sauer
+2  A: 

The two are not mutually exclusive.

The structure of the later AS versions are object-oriented, however it is not compiled into native assembler. It is instead interpreted as byte code.

dominic hamon
This. +1The way I think about it is that your SWF can't run on its own. It runs through a player, which interprets it. In my mind, that is the difference between a scripting language and a programming language.http://en.wikipedia.org/wiki/Scripting_language
Sean
@Sean, so you'd say Java is a scripting language?
Juan Pablo Califano
+2  A: 

Who says a scripting language can't be OO? I'd say it's both a scripting language and OO.

I mean, for instance, Python is often called a scripting language, and can be used simply to script existing applications. It's also OO. Both can in fact be merged if the software in question, say, requires you to pass in an object that adheres to a certain interface.

Devin Jeanpierre
It is definitely a scripting language, and definitely OO. It also is definitely NOT a programming language.
Devtron
+6  A: 

AS is a variant of ECMAScript. you can say it's a dialect of JavaScript.

as such, it has and has always had, OO qualities. it's not 'more' OO in 3.0 than before, it's just more "java-OO like" than before. because now it includes language support for class-based inheritance.

of course, the usual prototype based inheritance is still there, and it's a superset of class-based style.

and nothing of this makes it any less 'scripting' than before.

Javier
Both AS and JS are variants of JavaScript. I wouldn't call either of them dialects of the other. Otherwise, I agree. +1
Devin Jeanpierre
+1 for "java-OO like"
Ionuț G. Stan
ECMAScript is a specification. Both ActionScript and JavaScript are based on that spec. No variants here.
Luke
-1 for saying that is derived from JavaScript (especially Actionscript 3). They are two different languages.
Christopher W. Allen-Poole
read again, i never said anything about derivation. a 'dialect of' means "a related language, similar enough to be considered variants of each other". note that it's a symetric relationship, not an 'original/derivation' situation
Javier
Actually, Websters and American Heritage both state that if one thing is a dialect of another, then the former is a descendant of the latter. Ex. Mexicans speak a dialect of Spanish. Obviously, Spanish came before Mexico existed.
Christopher W. Allen-Poole
+1  A: 

Someone described ActionScript to me as an event oriented programming language. AS3 is a scripting language with OO features.

A: 

OK Thanks for the input guys, the best answers seem to be AS3 is both an OOP language and a scripting language. I guess this goes back to the definition of a scripting language - are scripting languages compiled? I have been equating AS3 and Java because both are compiled to byte code and run inside a VM, but I never hear java referred to as a scripting language, I guess I am still a bit confused...

I guess my question is now what distinguishes Java from AS3?

+1  A: 

what distinguishes Java from AS3?

Not a lot. Both generate bytecode that gets passed around, then compiled to machine code on the target platform through a JIT.

While AS3 is commonly described as belonging to the EcmaScript family, it has 2 co-existing object models under the hood. One is the traditional prototypical approach, while the other is a much more java-like approach, with packages, classes and interfaces, subclassing, abstract and final methods, etc.

Similarly, AS3 can be used without any explicit typing (just like javascript), or it can be used with strong typing, like Java. Unlike AS2, any type information given is encoded in the compiled bytecodes, and verified at runtime.

Note that the default compiler settings encourage developers to go toward the java-like flavor, but it's nothing that can't be fixed with a few options.

Essentially, ActionScript evolved from a toy language (See Flash 4 and below) to an javascript-like language (Flash 5 and 6), to an ecmascript language pretending to be something else (Flash 7 and 8) to something that has now more in common with Java and C# than with its own older incarnations (Flash 9 and 10)


To go back briefly to the original question, I can think of two language features that almost every scripting language has, that AS3 lacks:

  1. The ability to run a script from source directly. AS3 requires an explicit compilation step.
  2. The ability to evaluate a string at runtime as a code fragment. Don't look for an "eval" statement in AS3, it just doesn't exist.
Metal
Good answer. AS3 also lacks multiple inheritance, which proves to me that it's not a true OOP language, but rather a SCRIPT language.
Devtron
+1  A: 

Without defining what you mean by scripting language nobody can answer this question.

As Larry Wall puts it so well in Programming is Hard, Let's Go Scripting... : "I think, to most people, scripting is a lot like obscenity. I can't define it, but I'll know it when I see it." and "But basically, scripting is not a technical term. When we call something a scripting language, we're primarily making a linguistic and cultural judgment, not a technical judgment."

danio