 |
What is JavaScript?
|
JavaScript is the name of Netscape's implementation of ECMAScript,
a scripting programming language based on the concept of prototypes.
The language is best known for its use in websites, but is
also used to enable scripting access to objects embedded in
other applications.
Despite the name, JavaScript is only distantly related to
the Java programming language, the main similarity being their
common debt to the C programming language. JavaScript has far
more in common with the Self programming language.
JavaScript is a registered trademark of Sun Microsystems,
Inc., used under license for technology invented and implemented
by Netscape.
History
JavaScript was originally developed by Brendan Eich of Netscape
Communications Corporation under the name Mocha, then LiveScript,
and finally renamed to JavaScript. The change of name from
LiveScript to JavaScript roughly coincided with Netscape adding
support for Java technology in its Netscape Navigator web browser.
JavaScript was first introduced and deployed in the Netscape
browser version 2.0B3 in December of 1995. When web developers
talk about using JavaScript in Internet Explorer, they are
actually using JScript. The choice of name proved to be a source
of much confusion.
As of 2005, the latest version of the language is JavaScript
1.6, which corresponds to ECMA-262 Edition 3 like JavaScript
1.5, except for Array extras, and Array and String generics.
ECMAScript, in simple terms, is a standardized version of JavaScript.
The ECMA-357 standard specifies E4X, a language extension dealing
with XML.
Usage
JavaScript is a prototype-based scripting language with a syntax
loosely based on C. Like C, it has the concept of reserved
keywords, which (being executed from source) means it is almost
impossible to extend the language without breakage.
Also like C, the language has no input or output constructs
of its own. Where C relies on standard I/O libraries, a JavaScript
engine relies on a host environment into which it is embedded.
There are many such host environment applications, of which
web technologies are the most well known examples. These are
examined first.
One major use of web-based JavaScript is to write functions
that are embedded in or included from HTML pages and interact
with the Document Object Model (DOM) of the page to perform
tasks not possible in HTML alone, such as
- opening or popping up a new window,
- checking or validating web form input values,
- changing images as the mouse cursor moves over them, etc.
Unfortunately, the DOM interfaces in various browsers differ
and don't always match the W3C DOM standards. Rather than write
different variants of a JavaScript function for each of the
many browsers in common use today, it is usually possible,
by carefully following the W3C DOM Level 1 or 2 standards,
to provide the required functionality in a standards-compliant
way that most browsers will execute correctly. Care must always
be taken to ensure that the web page degrades gracefully and
is still usable by any user who
- has JavaScript execution disabled
- has a browser that does not understand the developer's
JavaScript
- is visually or otherwise disabled and may be using an unusual
browser, a speech browser or may have extreme text magnification
selected etc.
Other examples of JavaScript interacting with a web page's
DOM have been called DHTML and SPA.
A different example of the use of client-side JavaScript in
web pages is to make calls to web and web-service servers after
the page has loaded, depending upon user actions. These calls
can obtain new information, which further JavaScript can merge
with the existing page's DOM so that it is displayed. This
is the basis of Ajax programming that is seen by many to be
an important part of Web 2.0.
Microsoft's ASP technology has now been superceded by their
own ASP.NET platform, but it was possible, though rare, to
write server-side ASP code in JScript (their version of JavaScript)
that would create the HTML pages of such a web site. The normal
language for this server-side code was VBScript.
Outside of the Web, JavaScript interpreters are embedded in
a number of tools. Adobe Acrobat and Adobe Reader support JavaScript
in PDF files. The Mozilla platform, which underlies several
common web browsers, uses JavaScript to implement the user
interface and transaction logic of its various products. JavaScript
interpreters are also embedded in proprietary applications
that lack scriptable interfaces. Dashboard Widgets in Apple's
Mac OS X v10.4 are implemented using JavaScript. Microsoft's
Active Scripting technology supports JavaScript-compatible
JScript as an operating system scripting language. JScript
.NET is a CLI-compliant language that is similar to JScript,
but has further object oriented programming features.
Each of these applications provides its own object model which
provides access to the host environment, with the core JavaScript
language remaining mostly the same in each application.
Related languages
There is no real relationship between Java and JavaScript;
their similarities are mostly in syntax (that is, both derived
from C). Their semantics are quite different: notably, their
object models are unrelated and largely incompatible. Also
worth mentioning is Microsoft's own VBScript, which, like JavaScript,
is mainly used in web pages. VBScript has syntax derived from
Visual Basic and is only available on Internet Explorer.
Due to the success of JavaScript, Microsoft developed a compatible
language known as JScript. JScript was first supported in the
Internet Explorer browser version 3.0 released in August, 1996.
When web developers talk about using JavaScript in the IE browser,
they usually mean JScript.
The need for common specifications for the two languages was
the basis of the ECMA 262 standard for ECMAScript (see external
links below), three editions of which have been published since
the work started in November 1996 (and which in turn set the
stage for the standardization of C# a few years later). Implementations
of ECMAScript include JavaScript, JScript, and DMDScript. One
term often related to JavaScript, the Document Object Model
(DOM), is actually not part of the ECMAScript standard; it's
a separate standard, developed by the W3C, closely related
to XML.
ActionScript, the programming language used in Macromedia
Flash, bears a resemblance to JavaScript. ActionScript has
similar syntax to JavaScript, but the object model is dramatically
different.
JSON, or JavaScript Object Notation, is a general-purpose
data interchange format that is defined as a subset of JavaScript.
JavaScript OSA (JavaScript for OSA, or JSOSA), is a Macintosh
scripting language based on the Mozilla 1.5 JavaScript implementation,
SpiderMonkey. It is a freeware component made available by
Late Night Software. Interaction with the operating system
and with third-party applications is scripted via a MacOS object.
Otherwise, the language is virtually identical to the core
Mozilla implementation. It was offered as an alternative to
the more commonly used AppleScript language.
Of only historical interest now, ECMAScript was included in
the VRML97 standard for scripting nodes of VRML scene description
files.
About
this Tutorial
This tutorial is from The
Wikipedia which is published under the
GNU Free Documentation License.
Transforming a Generic Java IDE to Your Application Specific IDE One of the biggest challenges in application development today is how to factor in application-specific information. The answer lies in the ability to capture application evolution and developers' knowledge of building and extending the application as metadata so that it's not lost in time or translation. Once that can be done effectively, the combination of the application code along with application-specific metadata can be meaningfully packaged into reusable software asset modules. This white paper will discuss how 'Application Factories' can transform an IDE to play a central role in capturing both the application evolution and the developers' knowledge. Request Your Free Whitepaper!
|
|