Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will v8 implement ECMAScript 5?

I noticed that v8 is rather mute on the issue of ECMAScript 5th edition.

V8 implements ECMAScript as specified in ECMA-262, 3rd edition, and runs on Windows XP and Vista, Mac OS X 10.5 (Leopard), and Linux systems that use IA-32 or ARM processors.

Even the bug tracker seems quiet...

  • ECMA 5
  • Javascript 1.8

On one bug you can find a commiter writing this:

V8 is an implementation of ECMAScript, not JavaScript. The latter is a non-standardized extension of ECMAScript made by Mozilla. V8 is intended to be plug-in compatible with JSC, the ECMAScript implementation in WebKit/Safari. As such it implements a number of non-standard extensions of ECMAScript that are also in JSC, and most of these are also in Mozilla's JavaScript languages. There is no plan to add non-standard features that are not in JSC to V8.

Interestingly enough he wrote that on Oct 8, 2010, when ECMAScript 5 was published on December 2009, and two months earlier Javascript 1.8.5 -- a superset of ECMAScript 5 -- was released.

So the question remains when will Google update v8 to run on ECMAScript 5th edition? Is there even a plan to upgrade to the latest standardization of ECMAScript?

like image 356
NO WAR WITH RUSSIA Avatar asked May 25 '11 22:05

NO WAR WITH RUSSIA


People also ask

Should I use ES5 or ES6?

THE SHORT ANSWER: you should start with ES5 so that you'll have a better understanding of the language, but it's fine to go straight away to ES6 even though it's not fully supported in all browsers but you can get away with it especially if you're using some Javascript framework such as React it's going to be very ...

Is ES6 safe to use?

Since 2015, ES6 (ECMAScript 6) has been out for years and it has been accepted by most developers and has been proven safe and effective.

Is V8 engine a compiler?

Unlike other languages, The V8 engine uses both a compiler and an interpreter and follows Just in Time(JIT) Compilation for improved performance. Just in Time(JIT) Compilation: The V8 engine initially uses an interpreter, to interpret the code.


1 Answers

ECMAScript 5 was actually designed in such way so that implementations don't need to be "updated to run" on it.

There are few changes in existing behavior but mainly ES5 adds new native objects (e.g. Object.create, Array.prototype.map, String.prototype.trim, etc.) and standardizes some of the existing de-facto features (from ubiquitous "line terminators in string literals", "property access on strings", and "indirect eval behavior" to less popular "accessors" and array/string extensions).

The biggest change in behavior — strict mode — was made opt-in for the very same reason; to make transition from ES3 to ES5 less painful.

Having said that, V8 does implement a noticeable chunk of ES5 features, including strict mode (one of the recent additions).

If you look at my ES5 compat. table you can see ES5 features implemented in Chrome — which should closely (and I would think — completely) correlate to V8.

You can also see that support for strict mode is largely implemented in Chrome which means that it should be in V8 as well. To double check, I just ran this code in console (v8 v3.2.3.1) and got SyntaxError as expected:

> (function(){"use strict"; with({x:1}) return x})()
(shell):1: SyntaxError: Strict mode code may not include a with statement
(function(){"use strict"; with({x:1}) return x})()
                          ^^^^

So there you have it. V8 definitely implements majority of ES5 features, including strict mode ;)

like image 115
kangax Avatar answered Sep 20 '22 13:09

kangax