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...
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.
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.
AS 3.0 can be written as OO. Previous versions are more JavaScript like and procedural.
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.
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.
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.
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?
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:
- The ability to run a script from source directly. AS3 requires an explicit compilation step.
- 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.
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."