V8 is the name of the JavaScript engine that powers Google Chrome. It’s the thing that takes our JavaScript and executes it while browsing with Chrome.
V8是支持Google Chrome浏览器JavaScript引擎的名称。 这是需要我们JavaScript并在使用Chrome浏览器时执行它的东西。
V8 provides the runtime environment in which JavaScript executes. The DOM, and the other Web Platform APIs are provided by the browser.
V8提供了运行JavaScript的运行时环境。 DOM和其他Web平台API由浏览器提供。
The cool thing is that the JavaScript engine is independent by the browser in which it’s hosted. This key feature enabled the rise of Node.js. V8 was chosen to be the engine that powered Node.js back in 2009, and as the popularity of Node.js exploded, V8 became the engine that now powers an incredible amount of server-side code written in JavaScript.
很棒的事情是JavaScript引擎不受托管它的浏览器的影响。 此关键功能使Node.js的兴起成为可能。 V8在2009年被选为为Node.js提供支持的引擎,并且随着Node.js的爆炸性发展,V8成为了现在为大量用JavaScript编写的服务器端代码提供动力的引擎。
The Node.js ecosystem is huge and thanks to it V8 also powers desktop apps, with projects like Electron.
Node.js生态系统非常庞大,由于有了V8,V8还为桌面应用程序提供了支持,并支持Electron等项目。
Other browsers have their own JavaScript engine:
其他浏览器具有自己JavaScript引擎:
Firefox has Spidermonkey
Firefox拥有Spidermonkey
Safari has JavaScriptCore (also called Nitro)
Safari具有JavaScriptCore (也称为Nitro)
Edge has Chakra
边缘有脉轮
and many others exist as well.
还有很多其他的。
All those engines implement the ECMA ES-262 standard, also called ECMAScript, the standard used by JavaScript.
所有这些引擎都实现ECMA ES-262标准,也称为ECMAScript ,这是JavaScript使用的标准。
V8 is written in C++, and it’s continuously improved. It is portable and runs on Mac, Windows, Linux and several other systems.
V8用C ++编写,并且不断改进。 它是便携式的,可在Mac,Windows,Linux和其他几个系统上运行。
In this V8 introduction, I will ignore the implementation details of V8: they can be found on more authoritative sites (e.g. the V8 official site), and they change over time, often radically.
在此V8简介中,我将忽略V8的实现细节:可以在更权威的网站(例如V8官方网站)上找到它们,并且它们会随着时间的推移而发生根本性的变化。
V8 is always evolving, just like the other JavaScript engines around, to speed up the Web and the Node.js ecosystem.
与其他JavaScript引擎一样,V8也在不断发展,以加快Web和Node.js生态系统的速度。
On the web, there is a race for performance that’s been going on for years, and we (as users and developers) benefit a lot from this competition because we get faster and more optimized machines year after year.
在网络上,性能竞赛一直持续了多年,我们(作为用户和开发人员)从竞争中受益匪浅,因为我们年复一年地获得了更快,更优化的机器。
JavaScript is generally considered an interpreted language, but modern JavaScript engines no longer just interpret JavaScript, they compile it.
JavaScript通常被认为是一种解释语言,但是现代JavaScript引擎不再只是解释JavaScript,而是对其进行编译。
This happens since 2009 when the SpiderMonkey JavaScript compiler was added to Firefox 3.5, and everyone followed this idea.
自2009年将SpiderMonkey JavaScript编译器添加到Firefox 3.5以来,这种情况就发生了,每个人都遵循了这个想法。
JavaScript is internally compiled by V8 with just-in-time (JIT) compilation to speed up the execution.
JavaScript由V8 在内部进行即时编译 (JIT) 编译,以加快执行速度。
This might seem counter-intuitive, but since the introduction of Google Maps in 2004, JavaScript has evolved from a language that was generally executing a few dozens of lines of code to complete applications with thousands to hundreds of thousands of lines running in the browser.
这似乎是违反直觉的,但是自2004年Google Maps推出以来,JavaScript已经从一种通常执行几十行代码的语言演变为完整的应用程序,该应用程序在浏览器中运行着成千上万行。
Our applications now can run for hours inside a browser, rather than being just a few form validation rules or simple scripts.
现在,我们的应用程序可以在浏览器中运行数小时,而不仅仅是一些表单验证规则或简单的脚本。
In this new world, compiling JavaScript makes perfect sense because while it might take a little bit more to have the JavaScript ready, once done it’s going to be much more performant that purely interpreted code.
在这个新世界中 ,编译JavaScript非常有意义,因为虽然准备好 JavaScript可能需要花费更多时间,但是一旦完成,它将比纯解释代码具有更高的性能。
翻译自: https://flaviocopes.com/v8/