javascript被编译或解释 [英] javascript is compiled or interpreted

查看:88
本文介绍了javascript被编译或解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要教我的学生关于javascript

是这种编译语言还是因为谷歌向我透露了这个东西



V8将JavaScript编译为本机机器代码[ ^ ]



所以这意味着虽然js是解释语言,但我们可以使用v8谷歌引擎编译它...右???

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???

推荐答案

JavaScript的设计主要是解释语言,但是,是的,V8将JavaScript编译为本机机器代码。请阅读:

http://en.wikipedia.org/wiki/V8_ %28JavaScript_engine%29 [ ^ ] ,

https://developers.google.com/v8 [ ^ ]。



问题是:JavaScript动态行为是编译的严重障碍。无论如何,V8做它的功能。请阅读有关JavaScript的更多信息: http://en.wikipedia.org/wiki/JavaScript [ ^ ]。



但是, 编译可以通过其他一些方式应用于JavaScript,只是它不会使它成为编译语言。例如,Closure Compiler它从JavaScript编译成更好的JavaScript:

https://developers.google .com / closure / compiler [ ^ ]。



只有从这个意义上讲,它才被称为真正的编译器。术语编译非常广泛,因此您只需要关注编译语言的概念,而不是解释语言

http://en.wikipedia.org/wiki/Compiled_language [ ^ ],

http:// en.wikipedia.org/wiki/Interpreted_language [ ^ 无论如何,在某种意义上,有可能有这样的解释语言,允许创建原则上无法编译的代码。]。



这意味着唯一正确的编译需要创建一个具有嵌入式解释器的目标系统的整个模型(模拟器),该解释器将在运行时使用。创建这样的语言并不是一个小问题。



-SA
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


这篇关于javascript被编译或解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆