98

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...

  1. 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

  2. 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

  3. 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
  • 10
    You forgot to mention ActionScript, which is an ECMA dialect that is nothing to do with what you might call Javascript.
    – DaveRandom
    Commented Oct 22, 2012 at 20:17
  • 4
    Not so much for conformance (as you've already highlighted), but jslint is pretty nice for checking code. Commented Oct 22, 2012 at 20:19
  • 3
    @MadaraUchiha - I agree "just use jQuery. Everything will be ok." will not be okay. That is why I started researching this. My site bharath.lohray.com works well on Chrome and Firefox and the W3C validator does not generate any errors either, but it sucks big time on the newest IE! Moreover, as much as I like the idea of folks at anybrowser.org/campaign , I cannot be truly cross browser!
    – Lord Loh.
    Commented Oct 22, 2012 at 20:27
  • 8
    About your page, the scrolling is very annoying and over the top. Just IMO. And the "Lord" title sounds pompous as hell, even if you are actually a Lord. Commented Oct 22, 2012 at 23:05
  • 11
    It's unnecessarily flashy. You don't see posts sliding up and down on SE. If that's meant to be a professional looking website and you still want transitions, use something more discreet like a fade-in/fade-out. Commented Oct 22, 2012 at 23:27

2 Answers 2

97

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
  • 7
    If I could upvote your answer more than once, I would have done so :-) This does help make a few things more clear. The C compilers analogy makes the situation just a little understandable :-) Except JavaScript is not compiled to binary and the end users see non/quasi-functional scripts. So am I to understand that I cannot build a page to a standard and hope to have it function on all browsers the same yet? (yet being the operative word).
    – Lord Loh.
    Commented Oct 22, 2012 at 23:44
  • 1
    @LordLoh. That is correct. But you can allow libraries like jQuery and Prototype to abstract the differences away for you.
    – pdr
    Commented Oct 22, 2012 at 23:49
  • This post and the research started when jQuery animation did not work on IE9 and I lied the idea of the anybrowser.org campaign and was hoping I could stick to a standard. HTML5 / CSS3 / JS. The JS ended up as the bug in my bonnet.
    – Lord Loh.
    Commented Oct 22, 2012 at 23:57
  • 1
    @LordLoh. I wouldn't be so sure that's jQuery's fault. Just a quick glance shows up problems with your HTML (missing quotes, for example) and when you minimize your Javascript like that, there can be odd results if you've not been very accurate. I remember an issue long ago where I'd missed a semicolon and it only failed after compression in one of the major browsers. jQuery is pretty stable and should work well with IE9.
    – pdr
    Commented Oct 23, 2012 at 0:11
  • 5
    @LordLoh. console.log is your problem. It doesn't work unless you open the developer toolbar (and thus create object "console").
    – pdr
    Commented Oct 23, 2012 at 0:25
23

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.