"Home" of Javascript similar to python.org? - javascript

Perl, Ruby, Python, Javascript / ecmascript, PHP are all similar in the sense of being open source, open documentation, multi-platform, etc.
Perl has http://www.perl.org
Ruby has http://www.ruby-lang.org
Python has http://www.python.org
PHP has http://php.net
Is there a "home" for javascript in the same sense as these other languages?
When I say "home" I mean the go-to place for official documentation, specifications, source code of the language, examples, etc.

There's “JavaScript” the Mozilla-specific scripting language, for which the nearest to a home would probably be MDC, in particular the Core reference — though this has not been kept up-to-date with newer language developments, sadly.
And then there's ECMAScript, the standardised language that grew out of early Netscape work on JavaScript, and which is the basis for Mozilla's modernised JavaScript, IE's JScript, and the implementations in Opera, V8 (Chrome) and Squirrelfish (Safari), not to mention Flash's ActionScript.
This is driven by ECMA TC39 which produces the ECMA-262 standard. As a pure standards group, their materials are dry, unfriendly, and not really a suitable ‘home’ site at all. But if you want official that's all there is.
There is a real gap here for a user-readable doc site that covers standard ECMAScript, rather each vendor's own extended quirky version of it. (The canonical ECMA-262-5 is quite unreadable, even by the standards of standards documents.)

A very good place is https://developer.mozilla.org/en/JavaScript - they have tons of documentation there.

I will get burnt at the stake for this link, but for the 60%+ internet users out there who are using Internet Explorer (still), the MSDN reference is actually well documented.
It's the home of Javascript in the same way Simon Cowell is an authority on music though.

Related

Where is low level code of Javascript standard built-in objects?

I'm looking for the way to get low level code of javascript built-in function.
For example, there is an polyfill(I want like this form and I call this low level code in my way) in mdn site of 'Array.prototype.indexOf()'
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
And I get to understand that it is kinda low level code of built-in method.
Here is my question, where can I see the code to look inside of method of 'String.prototype.toLowerCase()'?
It'll depend on your javascript implementation.
For V8, here is the guts of toLowerCase (and toUpperCase)
Low level functions (such as these) are generally written in whatever language the javascript engine is written in - that's why they're so fast. So don't go in expecting something that's easy to read for the average javascript-only developer :)
The answer you are looking for probably doesn't exist but I'll do my best do help you out.
The low level function are dependent on which Engine you are using.
A few examples are:
V8 — open source, developed by Google, written in C++
Rhino — managed by the Mozilla Foundation, open source, developed entirely in Java
SpiderMonkey — the first JavaScript engine, which back in the days powered Netscape Navigator, and today powers Firefox
JavaScriptCore — open source, marketed as Nitro and developed by Apple for Safari
I assume you are looking for the function to understand what they are doing. If this is the case and you don't understand the languages that the engines are written it might be an idea to look at the polyfill implementation of those functions. Those are written in javascript and might help you understand them if that's what you are looking for.
Good luck! :)
JavaScript is defined by a standard, with many major implementations.
The definition for that method and others can be found in the TC39 website. It is only defined algorithmically, not in actual code.
That being said, for the open-source implementations, you can actually look at the source code for those implementations, though they will probably be in some other language, such as C++.
The major current open-source implementations of JavaScript are Google's V8, Apple's WebKit and Mozilla's SpiderMonkey.

Who standardizes the JavaScript language

As I understand it, ECMA International is responsible for defining the ECMAScript language specification (Reference number ECMA 262). This specification is implemented by certain languages, such as JavaScript or ActionScript. These languages are then transformed into a machine-readable form through an engine, such as V8 or SpiderMonkey.
What is still unclear for me is who is responsible for standardizing the JavaScript language itself? How is it possible that everybody writes the same JavaScript code if only the specification upon with the language is based seems to be standardized?
Javascript is being specified by a group of people called TC39. This group belongs to the ECMA international organization (Ecma International - European association for standardizing information and communication systems).
The specification is being developed publicly here.
Features find their way into the specification according to the TC39 process.
Discussions around proposals and the Javascript language also take place in a mailing group.
TC39 means Technical Committee number 39. It is part of ECMA, the institution which standardizes the JavaScript language under the “ECMAScript” specification. It works on the standardization of the general purpose, cross platform, vendor-neutral programming language that is ECMAScript. This includes the language syntax, semantics, libraries, and complementary technologies that support the language.
TC39 and the W3C collaborate wherever there is overlap between JavaScript and HTML5.
TC39 has bi-monthly face to face meetings, usually on the West Coast but one meeting per year takes place in Europe. In addition, at least one meeting is held in Redmond, WA (July meeting usually).
Attendance at meetings is controlled by Ecma International By-laws and Rules. Visitors on a one-time basis are usually approved by the Secretary General and requests should be directed to him for approval. Such visitors are kindly invited to fill in the Ecma International TC39 ECMAScript RFTG Contributor form.
TC 39 works on:
Maintaining and updating the standard for the ECMAScript programming language.
Identifying, developing and maintaining standards for libraries that extend the capabilities of ECMAScript.
Developing test suites that may be used to verify correct implementation of these standards.
Contributing with selected standards to the ISO/IEC JTC 1 committee.
Evaluating and considering proposals for complementary or additional technologies.
Reference Link
In the case of Actionscript - Adobe were much more proactive in adding features than the rest of the wwwc were at the time, this led to the creation of Actionscript 3.0, based on ECMA script version 4, which was never implemented for browser JS, which was a shame, though they were focusing on aligning ES5 with HTML5, and saving many of the ES4 proposed features for ES6 like the Class syntax, though this is still optional and legacy code is still compatible. While ES4/AS3 had mandatory class structure, and was gravitating to becoming a more like Java than Javascript, and consequentially, wasn't backwards compatible, which was a dealbreaker for the consortium.
So to answer your question - how can they be different? it's because the spec doesn't necessarily make it off the drawing board in all cases, and there's no mandate for a proprietary Language like Actionscript to stick to any standard, whilst JS should continue to adhere to them.
(Historically, Microsoft have tried to rock the boat, with jscript and it's proprietary features, and now Typescript with more of the same, but now JS is becoming a compile target, it allows companies like Microsoft to rock the boat as much as they want without getting in the way of the wwwc. Where we will still see disparity moving forward will be different languages compiling to JS, and JS compliant standards like webassembly that aren't built for human readability become more commonplace, but that's answering a whole other question.)

Internet Explorer Doesn't Support JavaScript?

I am recently reading about Node.js and got an interesting statement about JavaScript and Internet Explorer:
Internet Explorer doesn’t actually support JavaScript or ECMAScript; it supports a language variety called JScript. In recent years, JScript has fully supported the ECMAScript 3 standard and has some ECMAScript 5 support. However, JScript also implements proprietary extensions in the same way that Mozilla JavaScript does and has features that ECMAScript does not.
Source: http://chimera.labs.oreilly.com/books/1234000001808/ch01.html#chap2_id35941400
Frankly speaking I am totally unable to understand the above statement. I know Microsoft has its own VBScript and it allowed JavaScript in IE that is why JS is more popular than any other scripting language. Is this statement true? If yes then the scripting engine of IE does the translations of native JavaScript to JScript or what is the other case?
ECMAScript is the official standard, JavaScript and JScript are implementations of that standard. Just like CPython and Jython are implementations of Python.
As so often if it's about browsers, they both don't necessarily fully support the standard or provide additional, non-standard features, partly because they started evolving when an official standard didn't exist yet.
From Wikipedia about JScript:
[Microsoft] did not want to deal with Sun about the trademark issue, and so they called their implementation JScript. A lot of people think that JScript and JavaScript are different but similar languages. That's not the case. They are just different names for the same language, and the reason the names are different was to get around trademark issues
From the Microsoft documentation about JScript:
JScript is the Microsoft implementation of the ECMA 262 language specification (ECMAScript Edition 3). With only a few minor exceptions (to maintain backwards compatibility), JScript is a full implementation of the ECMA standard.
well, this mainly depends on the version of IE you are using, as you havent mentioned that no one can say that for sure
I think it is not like that instead Microsoft gives you an option to enable Javascript on your IE like this:
Pull down your TOOLS menu
Select Internet Options...
Click the Security tab on the top of the resulting window
Click the Custom Level button
Scroll the list down to the entry for Active Scripting
Check the Enable radio button.
Click OK in all dialogs.
Also Jscript is same as Javascript
JScript is Microsoft's dialect of the ECMAScript standard[2] that is
used in Microsoft's Internet Explorer.
JScript is implemented as a
Active Scripting engine. This means that it can be "plugged in" to OLE
Automation applications that support Active Scripting, such as
Internet Explorer, Active Server Pages, and Windows Script Host.[3] It
also means such applications can use multiple Active Scripting
languages (e.g., JScript, VBScript, PerlScript, etc.).

Why is JavaScript inconsistent across browsers?

Here's something I've been pondering after countless hours fixing JS to be cross-browser compatible (mostly IE): Why isn't Javascript consistent accross browsers?
I mean, why can't JS be nice like Java and Flash? Instead, we have to resort to frameworks like jQuery. Don't get me wrong, they make my life easier - but why do they even exist in the first place?
Is there a historical reason for this? Do companies rolling out browsers just ship their own JS engine? What are the politics that make standardization so difficult?
(Note: I understand that a good part of the problem is DOM related, but the question remains).
The Javascript core language for the most part is consistent ( Referring to ECMAScript version 3 released in 1999. )
It's the DOM implementations that cause headaches. Partly because at one point there was no DOM specification so browsers could do whatever the hell they wanted in terms of making up the rules for which to access and manipulate html elements in a web page.
For example:
window.addEventListener for DOM supporting browsers, while window.attachEvent for IE.
textContent for DOM supporting browsers, innerText for IE.
Memory leakage for attached event handlers in IE so you have to unload them manually
getElementById is buggy in IE and Opera because it returns elements by name
getAttribute('href') returns inconsistent values
There are also issues relating to the browser's CSS support.
IE6 doesn't support native PNGs so you are forced to use the filter library
Buggy animation in IE dealing with filter opacity
Language core inconsistencies would be things like
Inconsistencies between regex engines
But yeah, in short the point is that before, there was no standard. Since then, the w3 came up with standards, but every browser vendor has its own way of dealing with implementing it. There's no governing body that forces the vendors to fully apply the spec.
Do companies rolling out browsers just ship their own JS engine?
Yup, that's probably the main reason. There is no unified JS engine; there are various implementations of ECMAScript.
Browsers roll their own implementation, plain and simple. It's the same reason why rendering and CSS and all that are different across browsers. Java/Flash/etc. are more universal because they're abstracted out of the browser and accessed via a plugin of some sort. But their actual core implementations are separate from the browser and controlled by a single vendor.
To add to the other answers: there is a historical reason for this. I can write this myself, but quoting Wikipedia is easier on the fingers:
JavaScript was originally developed by
Brendan Eich of Netscape under the
name Mocha, which was later renamed to
LiveScript, and finally to JavaScript.
LiveScript was the official name for
the language when it first shipped in
beta releases of Netscape Navigator
2.0 in September 1995, but it was renamed JavaScript in a joint
announcement with Sun Microsystems on
December 4, 1995 when it was deployed
in the Netscape browser version 2.0B3.
[…]
JavaScript very quickly gained
widespread success as a client-side
scripting language for web pages. As a
consequence, Microsoft developed a
compatible dialect of the language,
naming it JScript to avoid trademark
issues. JScript added new date methods
to fix the non-Y2K-friendly methods in
JavaScript, which were based on
java.util.Date. JScript was included
in Internet Explorer 3.0, released in
August 1996. The dialects are
perceived to be so similar that the
terms "JavaScript" and "JScript" are
often used interchangeably. Microsoft,
however, notes dozens of ways in which
JScript is not ECMA-compliant.
In November, 1996 Netscape announced
that it had submitted JavaScript to
Ecma International for consideration
as an industry standard, and
subsequent work resulted in the
standardized version named ECMAScript.
As you can see, the standard, ECMAScript, was developed later than the original language. It's just a matter of adapting this standard in the current implementations of web browsers, that's still going on, as is the development of ECMAScript itself (e.g., see the specification of ECMAScript 5, published December 2009).

Why don't we just stop using the word JavaScript, in favor of ECMAScript?

The question says it all.
There is a difference between ECMAScript and JavaScript, isn't there?
ECMAScript is a well-defined language (spec here).
JavaScript is a dialect of it, not a full implementation as far as I understand, plus it contains what five generations of browsers did to it.
As Christoph points out in his comment, Microsoft's implementation of ECMAScript is actually called JScript, and the word "Javascript" is licensed to the Mozilla foundation.
The general perception, I think, is that of JavaScript as the sum of every browser's implementation of ECMAScript. It would be horrendously confusing to change that, and factually incorrect.
Say your question out loud and you will find it is its own answer.
If you spell it out then the five syllables of EEE-SEE-emm-EH script are quite a mouthful. And if you attempt to pronounce it as a word it will come out sounding like EczemaScript, which will lead to a rash of jokes.
Besides, "JavaScript" is the more than just widely used, it is embedded. No way are you going to be able to stop people saying "JavaScript".
edit
By a spooky coincidence I have just watched the Steve Yegge keynote from the OSCON 2007, in which he talks about branding and software. He touches on the issue of JavaScript vs ECMAScript. Without reaching a conclusion, it's true, but Steve is always good value. Watch it now.
The history of why it is called JavaScript is a convoluted one, and has a lot to do with making developers comfortable with the new language.
It was originally Mocha, then LiveScript, and finally JavaScript. Calling it JavaScript probably has a lot to do with why it was so widely adopted, as people assume it is similar to Java, and other C family languages that most programmers use every day. It actually has much more in common with Scheme and some of the more esoteric prototypal languages.
JavaScript is a well specified language, and is surprisingly well implemented accross all browsers. There are elements of the spec that cause major headaches, such as semicolon inference, but these are pretty consistent with the spec across all implementations.
It is the DOM library that causes 99% of the headaches with cross browser implementations in the real world.
As an addendum to the other answers:
HTML specs suggest using the text/javascript MIME type:
<script type="text/javascript">
Usually ECMAscript files are saved with file extension .js
Because ECMAscript is the standard and Javascript is an implementation (albeit a massively fragmented implementation). Which does not wholly support ECMAscript.
Because JavaScript Was its name (granted by Netscape) many years before Microsoft pushed through standardization by ECMA in an attempt to legitimize their independently developed JScript.
Historical reasons. Even if JavaScript™ is actually only the name of the ECMAScript dialect maintained by the Mozilla Foundation, I use the term Javascript (no capital 's') to encompass all common ECMAScript dialects.
Because ECMAScript is a name which refers to the language standardized by ECMA. JavaScript/JScript is one dialect of the language, but it's not the only one. There are other dialects like ActionScript. So the term "ECMAScript" doesn't only refer to JavaScript/JScript but also other dialects like ActionScript which are NOT what is embedded into browsers.

Categories