Can Javascript be considered an interpreted language when using Google Chrome (V8)?

I read this wonderful article about V8, the Google Javascript engine: https://developers.google.com/v8/design#mach_code .

At some point, they say that Javascript is compiled directly into machine language without any bytecode or interpreter.

Quote:

V8 compiles JavaScript source code directly into machine code when it is first executed. No intermediate byte codes, no translator.

So, why is Javascript still displayed along with the "scripting" and "interpreted" languages ​​when it is explicitly compiled (at least in V8)?



Edit: Is it possible to somehow create an executable from Javascript if it is compiled? Does this require somehow binding it to the V8?

Given this question, I found this quote:

V8 can work autonomously or can be integrated into any C ++ application.

Here: http://code.google.com/p/v8/ .

+6
source share
3 answers

That is why “interpreted language” and “compiled language” are examples of careless terminology. Whether a language is compiled or interpreted is an attribute of the implementation, not the language itself.

Many people confuse “dynamically typed languages” (like JavaScript) with “interpreted” and “statically typed languages” with “compiled” ones, but these are just correlations, not absolutes. You can compile a dynamic language (although it is usually more complicated than compiling a static one), and it can interpret a static language (for example: Hugs is an interpreter for Haskell).

+14
source

This is a scripting language because the JS code is intended for delivery and runs as source code.

If the encoder needs to provide a compiled binary for execution, then this will not be a script.

In addition, no matter what it does in Chrome, the same Javascript source should also work on other platforms, which can be a more or less traditional scripting environment. It also does not change the nature of the code itself as a script.

Even if you move on to compiling it, JS is still a scripting language. There are correct traditional compilers available for almost every scripting language you can think of (Perl, PHP ....); this does not prevent them from being script languages, and their source code is script.

Similarly, there are interpreters for many languages ​​that are traditionally compiled.

Finally, the problem is further confused by the concept of "compiling" one language into another. It was a while, but the idea really came off languages ​​like Coffeescript, which are meant to be compiled into Javascript. So what do you call Coffeescript compiled code?

The terminology is actually not all that useful, especially now, but the final answer to your question in the context you ask him is that yes, Javascript is still a scripting language.

+2
source

Here, let me have a demo code:

later(); // prove that js is a compiling language function later(num) { console.log("Your number is: " + num); } 

This piece of code can work both in the Chrome browser and in Node js.

If someone says that js is an interpreted language, then this piece of code will crash, because when u starts later (), it does not need to know the later part of the function.

This can prove that js is a compiled language, since it compiles a later function (so that the machine could know it), and then execute it.

+1
source

Source: https://habr.com/ru/post/920160/


All Articles