All this started when I was looking for a way to test my webpage for JavaScript conformance like the W3C HTML Validator. I have not found one yet. So let me know if you know of any…
-
I looked for the official JavaScript page and find ECMA Script. These people have standardized a scripting language (I do not feel like calling it JavaScript anymore!) and called it ECMA-262 (Wikipedia). Their latest work is Edition 5.1
-
JavaScript was developed by Mozilla Corporation and their last stable version is 1.8.5 (see this) which is based on the ECMA’s edition 5.1
-
The Wikipedia page linked mentions dialects. Mozilla’s JavaScript 1.8.5 is listed as a dialect along with JScript 9 (IE) and JavaScript (Chrome’s V8[Wiki]) and a lot others. Am I to understand that JavaScript 1.8.5 is a derivative of the ECMA-262 and SpiderMonkey[Wiki] is an engine that runs it? And Chrome has its own dialect and V8 engine is the program that runs it?
With all these dialects based off ECMA-262, what I can no longer understand is “What is JavaScript“? Are there any truly cross browser scripting languages? Do the various implementers come together to agree on the dialect cross compatibility? Is this effort ECMA?
9
Pretty much all mature languages are defined by a specification, and compilers or interpreters attempt to follow the standard defined in that specification. But very rarely do they succeed, unless the standard is defined by the author of the language.
You can find the C++ 2003 standard, the C# 4 specification, the Java 7 specification and many more online. Many of these have ECMA or ISO standardisation numbers. These are just organisations with which you can register a standard and make it more official.
Ruby has historically done things a little differently, having an executable set of tests as a specification. So, if you want to write an interpreter and call it standard Ruby, you just had to create an interpreter that passed all of those tests. But even Ruby is likely to become a more formal specification eventually.
Javascript is no different, except possibly in the way it has evolved.
Javascript was first created by Netscape. They called it LiveScript, but it looked similar to Java and they cut a deal with Sun over the name, which benefited both the marketing of Netscape and Java. Microsoft had VBScript and (for reasons probably lost to conjecture) basically copied Javascript, but the name was owned by Sun, so they cheekily called it JScript.
But JScript, while being very similar to Javascript in syntax, made a lot of use of COM — for example, IE5 and 6 instantiate an XMLHttpRequest object using new ActiveXObject("Microsoft.XMLHTTP");
.
And so, parallel, similar but also different “dialects” of Javascript were born. Over time, various groups owning browsers with less market share than IE have tried to standardise the language, and for years Microsoft resisted. Until V8.
V8 was fast. It set a whole new market standard. It made everything else look poor.
And, through various antitrust cases against Microsoft, IE was losing market share. Suddenly, it was in Microsoft’s interest to support standardisation. We’re not there yet, but it’s on the right track.
Meanwhile, V8 was open-source, which allowed people to start thinking up new uses for a fast Javascript parser, such as Node.JS.
But, to go back to your question: What is Javascript? It’s the common (and original) name for ECMAScript, a specification for a prototypical language commonly, but not exclusively, used for navigating and manipulating the domain object model in a broswer.
ECMA-262 is just the standard definition, like ECMA-334 is the standard definition for C#. ECMAScript was the only name that all the interested parties could agree on, back in ’99, when ECMA-262 was written.
11
Javascript is a commonly used implementation of ECMAScript. It’s a very similar situation to the Scheme family. In Scheme, you have a highly formalized specification. The current version is R6RS though R5RS is by far the more commonly implemented standard as of this post. The implementations are more scattered than ECMAScript’s due to Scheme’s age and general philosophies.
Javascript happens to be common now largely due to the explosive growth in market share of both Mozilla’s Firefox and Google’s Chrome. It gained a foothold originally with Netscape Navigator which eventually turned into the Mozilla browser and then into Firefox (and Iceweasel if you run with the Scheme crowd).
Now here’s where it gets a little dicey. Most of Javascript’s performance comes from the parser and engine running it. This is where the real differences between browsers become apparent. Spidermonkey runs Javascript differently than V8 does. Javascript still have rough spots like the lack of a fully common library, though that’s being worked on.
So if Javascript were C++, then ECMAScript would be the C++11, with UNIX and G++ being the closest to “standard” while C++ for .NET and Objective C++ lie further afield much in the way Actionscript does from ECMAScript