4 ms·
The v8 engine in Chrome and node is a JIT compiler not an interpreter. Moreover it even compiles to machine code: https://en.wikipedia.org/wiki/V8_(JavaScript_
by laumars 5y ago
The v8 engine in Chrome and node is a JIT compiler not an interpreter. Moreover it even compiles to machine code:
https://en.wikipedia.org/wiki/V8_(JavaScript_engine) https://en.wikipedia.org/wiki/V8_(JavaScript_engine)
You’d have more luck if you exampled Bash scripting :P
If you want to be pedantic then these days even those languages that were considered “interpreted” have had their interpreters rewritten to produce byte code that is generally closer to machine code than it is the original source. So they’ve grown beyond the original definition of “interpreted” and evolved into something much closer to a compiled languages.
So if think it’s disingenuous to still call them “interpreted”. And in the case of JavaScript (your example), the largest runtime in use is most definitely a compiler considering it spits out machine code. So that’s definitely not interpreted like you’ve claimed.
- zingplex 5y agoV8 does actually include a bytecode interpreter called Ignition to reduce memory usage on stuff that doesn't really need to be heavily optimized.
- laumars 5y agoIt contains a byte code compiler. The point is that one of the stages of the compiler rather than the byte code being interpreted at runtime. In the link I posted: > V8 first generates an abstract syntax tree with its own parser.[12] Then, Ignition generates bytecode from this syntax tree using the internal V8 bytecode format.[13] TurboFan compiles this bytecode into machine code. In other words, V8 compiles ECMAScript directly to native machine code using just-in-time compilation before executing it.[14] The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code's execution profile. Optimization techniques used include inlining, elision of expensive runtime properties, and inline caching. The garbage collector is a generational incremental collector.[15] Emphasis mine. So no, it is not an interpreter. It is definitely a compiler. It seems people today are confusing “interpreter” with “just in time”…
- zingplex 5y agoYou're right, ignition does generate bytecode from the AST; it also interprets it. > With Ignition, V8 compiles JavaScript functions to a concise bytecode, which is between 50% to 25% the size of the equivalent baseline machine code. This bytecode is then executed by a high-performance interpreter which yields execution speeds on real-world websites close to those of code generated by V8’s existing baseline compiler. Emphasis mine. https://v8.dev/blog/ignition-interpreter https://v8.dev/blog/ignition-interpreter You can also find this information on the Wikipedia article you linked to > In 2016, the Ignition interpreter was added to V8 with the design goal of reducing the memory usage on small memory Android phones in comparison with TurboFan and Crankshaft. Ignition is a Register based machine and shares a similar (albeit not the exact same) design to the Templating Interpreter utilized by HotSpot. > In 2017, V8 shipped a brand-new compiler pipeline, consisting of Ignition (the interpreter) and TurboFan (the optimizing compiler).
- laumars 5y agoHere lies the problem. Just because a component of the v8 compiler is called an “interpreter” it doesn’t mean that JavaScript (via v8) is an interpreted language. Which is the point I’m making. Back in the 80s and 90s scripting languages often had no compilation stage aside maybe building an AST and were pretty much 100% interpreted. Anything that ran from byte code was considered compiled (like BASIC vs Java, VB6). Interpreters often ran line by line too. These days most scripting languages that were traditionally interpreted languages run more like Java except compiled JIT rather than AOT. But it seems people have warped “interpreted” to mean JIT to compensate for the advancements in scripting runtimes. That is a bastardisation of the term in my opinion. But when you look through this thread you’ll see the same error repeated over and over.
- saagarjha 5y agoNo, that isn't true. Java and JavaScript are typically run through a good, optimizing JIT runtime; Python rarely is. Hence the general classification.