Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
2.33/5 (5 votes)
See more:
what i need to teach my student about javascript
is this compile language or interpreted because google reveal this thing to me that

V8 compiles JavaScript to native machine code [^]

so it means although js is interpreted language but we can compile it using v8 google engine...right???
Posted
Comments
PIEBALDconsult 22-Oct-14 14:13pm    
The language itself doesn't care.
Sergey Alexandrovich Kryukov 22-Oct-14 14:36pm    
This is a right idea, but I don't think this is always the case, even if this is the case with JavaScript. It's possible to have a language which allows to create code which cannot be compiled in principle. Frankly, I even suspect that is the case of JavaScript, but it needs serious research. Please see my answer.
—SA
Muhamad Faizan Khan 22-Oct-14 14:26pm    
language itself doesn't care meanse no matter js interpreted or compiled..hmm
Sergey Alexandrovich Kryukov 22-Oct-14 14:36pm    
This is a right idea, but I don't think this is always the case, even if this is the case with JavaScript. It's possible to have a language which allows to create code which cannot be compiled in principle. Frankly, I even suspect that is the case of JavaScript, but it needs serious research. Please see my answer.
—SA
Sergey Alexandrovich Kryukov 22-Oct-14 14:38pm    
Despite of your naive post (you already got a vote of 1 from anyone), this make a very interesting question, so I voted 4.
However, low vote probably also may make some sense, because you could read more on the topic before asking; and because you need to be very responsible, to be a teacher.
—SA

1 solution

JavaScript is a predominantly interpreted language by its design, but, yes, V8 compiles JavaScript to native machine code. Please read about it:
http://en.wikipedia.org/wiki/V8_%28JavaScript_engine%29[^],
https://developers.google.com/v8[^].

The problem is: JavaScript dynamic behavior presents a serious barrier for compilation. Anyway, V8 does what it does. Please read more about JavaScript: http://en.wikipedia.org/wiki/JavaScript[^].

However, "compilation" can be applicable to JavaScript in some other ways, only it doesn't make it a compiled language. For example, Closure Compiler "it compiles from JavaScript to better JavaScript":
https://developers.google.com/closure/compiler[^].

Only in this sense, it's claimed to be a "true compiler". The term "compilation" is very wide, so you need to focus only on the notion of compiled languages, vs. interpreted languages:
http://en.wikipedia.org/wiki/Compiled_language[^],
http://en.wikipedia.org/wiki/Interpreted_language[^].

Anyway, in certain sense, it is possible to have such interpreted language which allows to create code which cannot be compiled in principle. It means that the only correct compilation would need to create a whole model (simulator) of target system with embedded interpreter which would be used during runtime. Creation of such language is not a trivial problem.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900