Author, copywriter, editor | Сreation and optimization of varied information content
V8 is written in C++, and can run standalone or be embedded into the C++ app. It is portable and runs on:
"It doesn't matter if you run it in the browser or Node.js or an IoT device: to go from something that you write to executing that - that's what the engines are doing. JS engines are the heart of everything that we do", - Franziska Hinkelmann, Senior Engineer at Google
PREHISTORY: LET'S START THE ENGINE!
This open-source JS engine came into being with the Chromium Project for Google Chrome and more Chromium browsers. Lars Bak, a danish programmer, was a project's creator and he's the one who led the V8 team. This man is a true virtual machine expert and guru of object-oriented design. By the way, Lars Bak spent 30 years developing programming languages. Once upon a time, he implemented a runtime system for BETA. Since then, Mr. Bak has left marks on a dramatic list of different software systems and finally get to the V8. How it was?
It is interesting that V8's subprocesses are named in accordance with automotive details. That is not only a stylish brand idea. It's also a good way for users to gain insight into JS engine behavior.
"I like how they changed the names of the processing of the V8 engine to stuff like "ignition" and "turbofan". It's easier to remember because it's like a car engine now", - Ksee, YouTube user
In the basic terms, JS engine:
And what is making code runs so fast? Let's consider some interesting V8's characteristics.
Interpreted or compiled?
JS is usually perceived as an interpreted language, but its modern engines are much more than just interpreters in order to get a more performant execution. The basis of the V8 that allows a high-speed JS executing is the JIT (Just-In-Time) compiler optimizing code during runtime (not Ahead-Of-Time). It combines the best features of interpreters and compilers, mixing these steps and making translation and execution faster.
The first optimizing compiler of V8 was "FullCodegen". The newest and more advanced is "Turbofan". Its backend is used by the V8's low-level register-based interpreter called 'Ignition'. This combined Ignition+TurboFan pipeline was launched in 2017.
In 2018 was released Liftoff, WebAssembly's (Wasm) first-tier compiler in V8 for a fast startup of complex websites with big Wasm modules, for example, Google Earth.
Keep calm and maintain cleanliness
Over the past years, V8's developers worked on the garbage collection process improvement a lot. Finally, they implemented a 2 generation-based garbage collector (also known as a full GC) called "Orinoco". It applies the latest effective techniques to free the thread. Collector finds objects and data that are no longer referenced and collects them. This contributes to well-improved latency and page load, smoother animation, scrolling, and user interaction.
In 2018, Chromium team started a project called V8 Lite. The main aim was a forcefully reducing memory usage.
Originally, it was intended as a Lite mode for low-memory devices or embedded use-cases. But soon developers decided to fully implement that optimization bonuses in the regular V8, advancing all vee-eight usage areas. You can consult technical details of memory savings and improved execution speed without wizardry in V8's official blog.
"Our philosophy is that if you make a quick feedback loop, from programming to receiving feedback from the running system, in under a second, it inspires the programmer to experiment and invent new things", -
Lars Bak, danish programmer, the tech lead of V8 project
There is a short list of presented developer-facing goodies:
All those v.8.0 highlights are especially enjoyable in anticipation of the new Chrome release. Chrome 80 Stable will be released on February 4th, 2020, as reported by Chromium. So let's check bug fixes and performance improvements and drive on with V8 JS in 2020!
This article was originally posted on Freschode blog where you can find more articles about web development.