有JavaScript的本地机器代码编译器吗? [英] Is there a native machine code compiler for JavaScript?
问题描述
有JavaScript的本地机器代码编译器吗?
我不在说VM。
如果它不存在可以做到吗?
我想知道是否可以编译成二进制由于语言的动态性质。
Is there a native machine code compiler for JavaScript?
I'm not talking about a VM.
If it doesn't exist can it be done?
I am wondering if it can be compiled to binary due to the dynamic nature of the language.
推荐答案
据我所知,没有JavaScript的静态编译器。这在理论上是可能的;然而,JavaScript的静态编译将需要一个非常重的运行时来支持其所有的功能(如动态类型和eval)。作为一个小问题,当需要静态编译Python(另一种动态语言)时, PyPy 开发人员最终创建了一个语言,这是一个非常有限的Python子集(称为RPython),没有一些Python的更动态的特性,能够静态编译。
As far as I know, there are no static compilers for JavaScript. It is certainly theoretically possible; however, a static compilation of JavaScript would need a very heavyweight runtime to support all of its features (such as dynamic typing and eval). As a small aside, when presented with the need to statically compile Python (another dynamic language), the PyPy developers ended up creating a language which was a very restricted subset of Python (called RPython), void of some of Python's more dynamic features, that was capable of being statically compiled.
如果你要求这是为了从JavaScript代码创建一个独立的可执行文件,我确信必须有包装器,本质上将创建一个可执行文件包含你的脚本和嵌入式JavaScript VM(可悲的是,我不知道有什么不好意思)。
If you're asking this for the purpose of creating a standalone executable from JavaScript code, I'm sure there must be wrappers which essentially would create an executable containing your script and an embedded JavaScript VM (sadly, I don't know any offhand).
这篇关于有JavaScript的本地机器代码编译器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!