Jump to content

JavaScript engine

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Jondel (talk | contribs) at 07:09, 3 July 2010 (→‎External links). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A JavaScript engine is a specialized software program that processes JavaScript, especially for web browsers.

History

Before the second browser wars in 2008-2009, the JavaScript engine (also known as JavaScript interpreter or JavaScript implementation) was known simply as an interpreter that reads JavaScript source code and executes the script accordingly.

The first ever JavaScript engine was created by Brendan Eich at Netscape Communications Corporation, for the Netscape Navigator web browser. The engine, code named SpiderMonkey, is implemented in C. It has since been updated (in JavaScript 1.5) to conform to ECMA-262 Edition 3. The Rhino engine, created primarily by Norris Boyd (also at Netscape) is a JavaScript implementation in Java. Like SpiderMonkey, Rhino is ECMA-262 Edition 3 compliant. Applications of the technology include Apple Safari 4's Nitro, Google Chrome's V8 and Mozilla Firefox 3.5's TraceMonkey.

By far, the most common host environment for JavaScript is a web browser. Web browsers typically use the public API to create "host objects" responsible for reflecting the DOM into JavaScript.

The web server is another common application of the engine. A JavaScript webserver would expose host objects representing a HTTP request and response objects, which a JavaScript program could then manipulate to dynamically generate web pages. Microsoft's ASP technology for IIS allows server-side code to be written in VB Script or JScript (Microsoft's implementation of JavaScript). Jaxer is a web server that runs entirely on JavaScript. This has the benefit of allowing the same code to be shared on the server and on the client.

JavaScript engines

Major browser JS engines:

Mozilla

  • Rhino, managed by the Mozilla Foundation, open source, developed entirely in Java
  • SpiderMonkey (code name), the first ever JavaScript engine, written by Brendan Eich at Netscape Communications
  • JägerMonkey, the engine in development for Mozilla Firefox.
  • Tamarin

Google

  • V8 - open source, developed by Google in Denmark, part of Google Chrome

Other

Performance evolution

Released June 30, 2009 Firefox 3.5 includes the optimization technique which offered "performance improvements ranging between 20 and 40 times faster in some cases"[2]

On June 2, 2008 the WebKit development team announced SquirrelFish[3] — a then new JavaScript engine that vastly improves Safari's speed at interpreting scripts.[4] The engine was one of the new features in Safari 4, released for developers on June 11, 2008; the final JavaScript engine was called Nitro.

There has since been a race by browser developers to develop even faster JavaScript engines. In 2008, Google Chrome was praised for its JavaScript performance, but other browsers soon received new JavaScript engines which were faster. Later, Google Chrome won in the races of better performance. Chrome's strength is its application performance and JavaScript processing speed, both of which were independently verified by multiple websites to be the fastest amongst the major browsers of its time.[5][6][7] With the advent of WebKit's Squirrelfish Extreme and Mozilla's TraceMonkey JavaScript virtual machines, Chrome's JavaScript execution performance has been found to be slower.[8][9][10][11] Google responded with the Danish developed V8 (JavaScript engine) which boosted JS performance in Google Chrome 2.

A typical major browser has a graphical engine and an independent JavaScript engine, which allows for easier testing, reimplementation or usage in other projects. For example Carakan is used with Presto, Nitro with WebKit, SpiderMonkey with Gecko, KJS with KHTML, Rhino by default doesn't have any layout engine. Other combinations are sometimes possible, for example, V8 with WebKit in Google Chrome. The JavaScript engine gives developers access to functionality (networking, DOM handling, external events, HTML5 video, canvas and storage) needed to control the web browser.

Sunspider is a JavaScript benchmark utility for measuring the performance of JavaScript engines in more than a dozen of tests, each concentrating on different part of JavaScript language. Sunspider doesn't use for benchmarking any features beyond this needed to test pure computations (no HTML, no CSS, no networking).

Implementations

JavaScript is a dialect of ECMAScript, which is supported in many applications, especially web browsers. Dialects sometimes include extensions to the language, or to the standard library and related APIs such as the W3C-specified DOM. This means that an application written in one dialect may be incompatible with another, unless the applications are written to use only a common subset of supported features and APIs.

Note that there is a distinction between a dialect and an implementation. A dialect of a language is significant variation of the language, while an implementation of a language/dialect executes a program written in that language/dialect.

Application Dialect and latest version ECMAScript edition
Google Chrome, the V8 engine JavaScript ECMA-262, edition 3
Mozilla Firefox, the Gecko layout engine, SpiderMonkey, and Rhino JavaScript 1.8.1 ECMA-262, edition 3
Opera ECMAScript with some JavaScript 1.5
and JScript extensions[12]
ECMA-262, edition 3
KHTML layout engine, KDE's Konqueror, and Apple's Safari JavaScript 1.5 ECMA-262, edition 3
Adobe Acrobat JavaScript 1.5 ECMA-262, edition 3
OpenLaszlo Platform JavaScript 1.4 ECMA-262, edition 3
Max/MSP JavaScript 1.5 ECMA-262, edition 3
ANT Galio 3 JavaScript 1.5 with RMAI extensions ECMA-262, edition 3

References

  1. ^ Marius Oiaga (2010-03-20), "Internet Explorer 9 Beta Next – New IE9 Builds Every 8 Weeks", softpedia.com, SoftNews NET SRL, retrieved 2010-06-28
  2. ^ Ryan Paul (2008-08-22). "Firefox to get massive JavaScript performance boost". arstechnica.com. Ars Technica © 2010 Condé Nast Digital. Retrieved 2010-06-28.
  3. ^ Garen, Geoffrey (2008-06-02). "Announcing SquirrelFish". Retrieved 2008-06-11.
  4. ^ Lipskas, Vygantas (2008-06-11). "Apple Safari 4". Retrieved 2008-06-11.
  5. ^ Stephen Shankland (2008-09-02). "Speed test: Google Chrome beats Firefox, IE, Safari". cnet.com Business Tech. CNET News. Retrieved 2010-06-28.
  6. ^ "Big browser comparison test: Internet Explorer vs. Firefox, Opera, Safari and Chrome". PC Games Hardware. Computec Media AG. Retrieved 2010-06-28.
  7. ^ "Lifehacker Speed Tests: Safari 4, Chrome 2". Lifehacker. Retrieved 2010-06-28.
  8. ^ Stephen Shankland (2008-09-02). "Third Chrome beta another notch faster". cnet.com. CNET News. Retrieved 2010-06-28.
  9. ^ Stephen Shankland (2008-09-19). "Step aside, Chrome, for Squirrelfish Extreme". cnet.com. CNET News. Retrieved 2010-06-29.
  10. ^ "SquirrelFish Extreme: Fastest JavaScript Engine Yet". satine.org. Retrieved 2010-06-29.
  11. ^ Stephen Shankland (2008-09-03). "Firefox counters Google's browser speed test". cnet.com Business Tech. CNET News. Retrieved 2010-06-29.
  12. ^ "Web specifications support in Opera Presto". Opera.com. Opera Software ASA. Retrieved 2010-06-28.

See also