views:

424

answers:

4

I have a book, Essential ActionScript 3 (O'Reilly), to learn about using that language. It mentions that ActionScript 3 is an implementation of ECMAScript, just like Javascript. I find this strange, because there are many differences. In Javascript, as far as I know, you cannot give variables a type (var marvin : Robot) or create "traditional" classes and interfaces. This is, however, possible in ActionScript.

What's up?

A: 

Wikipedia's page about ECMAScript states (quoting) :

ECMAScript is a scripting language, standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used on the web, especially in the form of its three best-known dialects, JavaScript, ActionScript, and JScript.

So I'm guessing that those three languages sort-of are "children" of ECMAScript, and that each of those choose to implement (or not) some specific features -- while all keeping the same root.


The page about ActionScript kind of confirms that, stating (quoting, emphasis mine) :

ActionScript is a scripting language based on ECMAScript.

I suppose this "based on" is the important part.


Also, there might be a difference depending on the version of ECMAScript that is used, I'd say -- especially considering people are talking about ECMAScript 5, and that, for instance, Javascript is based on ECMAScript 3 :

As of 2009, the latest version of the language is JavaScript 1.8.1. It is a superset of ECMAScript (ECMA-262) Edition 3.

Pascal MARTIN
They're all required to run programs written to the ecmascript 3 spec. They all come pretty close. The differences that make Ecmascript 3 not quite a subset of those languages are edge cases, not big banner features. The rest is proprietary extensions, which are allowed.
Breton
+9  A: 

The current implementations of Javascript in browser follows Ecmascript 3 specification. Actionscript implements Ecmascript 3 but in addition, some of the elements in Ecmascript 4 draft specification (at that time). ES4 features Classes, classical inheritance, packages and other features you see in AS3.

ES4 is now abandoned but here is a link to the specs PDF.

Chetan Sastry
A: 

ECMAScript is just a standard for a scripting language. Javascript and Actionscript are both implementations of that standard. Each implementation may or may not strictly follow that standard, and both are free to add to and subtract from it.

Scott
Depending on who you ask, you can't implement a standard if you leave things out.
Bart van Heukelom
A: 

ActionScript 1 (Flash Player 5 and 6) is very close to JavaScript.

Honestly, I don't understand this "-1".
The question specifically mentions AS _3_
Bart van Heukelom
I think this is a detail...