JIT编译器是编译器还是解释器?
我的问题是,将 IL 转换为机器语言的 JIT 编译器究竟是编译器还是解释器。
还有一个问题: HTML、JavaScript是编译型语言还是解释型语言?
提前致谢
My question is whether JIT compiler which converts the IL to Machine language is exactly a compiler or an interpreter.
One more question :
Is HTML, JavaScript a compiled language or interpreted language?
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
JIT(just in time)编译器是一种编译器。它进行优化以及编译为机器代码。 (甚至称为编译器)
HTML、Javascript 被解释,它们由网络浏览器按原样读取,并以最少的错误修复和优化运行。
JIT (just in time) compiler is a compiler. It does optimizations as well as compiling to machine code. (and even called a compiler)
HTML, Javascript are interpreted, they are read as-is by the web browser, and run with minimal bug fixes and optimizations.
从技术上讲,编译器将一种语言翻译为另一种语言。由于 JIT 编译器接收 IL 作为其输入并输出本机机器二进制文件,因此它很容易符合此标准,并且应该称为编译器。
对于Javascript,这里区分比较困难。如果你想迂腐的话,没有“编译语言”或“解释语言”这样的东西。我的意思是,实际上,大多数语言确实有一种常见的运行方式,如果这是解释器,它们通常被称为解释语言,但解释或编译(通常)不是语言本身的特征。 Python 几乎普遍被认为是解释型的,但可以编写一个编译器将其编译为本机二进制代码;它仍然值得“解释”这个形容词吗?
现在得到实际的答案:Javascript通常由解释器运行,除其他外,解释器本身使用 JIT 编译器。那么这是解释的还是编译的?你的电话。
Technically, a compiler translates from one language to another language. Since a JIT compiler receives an IL as its input and outputs native machine binary, it easily fits this criteria and should be called a compiler.
Regarding Javascript, making a distinction here is more difficult. If you want to be pedantic, there's no such thing as a "compiled language" or "interpreted language". I mean, it's true that in practice most languages have one common way of running them and if that is an interpreter they are usually called interpreted languages, but interpretation or compilation are (usually) not traits of the language itself. Python is almost universally considered interpreted, but it's possible to write a compiler which compiles it to native binary code; does it still deserve the "interpreted" adjective?
Now to get to the actual answer: Javascript is typically ran by an interpreter which, among other things, uses a JIT compiler itself. Is that interpreted or compiled, then? Your call.
从维基百科来看,
即时编译器(JIT)
也称为动态翻译器,用于提高计算机程序的运行时性能。即时编译
是在执行之前将非本机代码(例如字节码)转换为本机代码。JIT编译器
是编译IL 代码并输出缓存的本机代码,其中作为解释器将逐行执行代码,即,对于java,类文件是解释器的输入。
有关 JIT 的更多信息,请参见:
是的,解释 HTML、JavaScript语言,因为它们没有编译成任何代码。这意味着脚本无需预先编译即可执行。
也是一本好书这里关于JavaScript/HTML不是编译语言。
From Wiki's ,
just-in-time compiler(JIT)
, also known as dynamic translator, is used to improve the runtime performance of computer programs.Just-in-time compilation
is the conversion of non-native code, for example bytecode, into native code just before it is executed.JIT compiler
is the one who compiles the IL code and output the native code which is cached, where as an interpreter will execute line by line code,i.e in the case of java the class files are the input to the interpreter.
More on JIT here :
Yes, HTML, JavaScript are interpreted languages since they aren't compiled to any code. It means that scripts execute without preliminary compilation.
Also a good read here on JavaScript/HTML not being the compiled languages.
像 IL 这样的 JIT 处理器大部分都是编译器。 JavaScript 处理器主要是解释器。我理解您对这个问题的好奇心,但我个人认为确实没有任何“正确”的答案。
出于效率原因,有些 JavaScript 解释器可以编译部分或全部代码。那些真的是口译员吗?
JIT 在运行时起作用,因此它可以被理解为一个聪明的、高度优化的解释器。是哪一个?
这就像“这是一种植物”或“这是一种动物”的问题。有些生命体并不完全符合这两种模式:自然就是自然,而事物的“分类”纯粹是人类智力的努力,有其局限性。即使像“代码”这样的人造事物也受到同样的考虑。
好的;所以也许有一个正确的答案:
JavaScript 的处理方式(比如 5 年前)被称为“解释器”。 C++ 的处理方式被视为“编译器”。
IL 的处理方式很简单...'JIT'。
JIT processors like IL are compilers, mostly. JavaScript processors are interpreters, mostly. I understand your curiosity for this question, but personally I've come to think that there really isn't any 'right' anwser.
There are JavaScript interpreters that compiler parts or all of the code for efficiency reasons. Are those really interpreters?
JIT acts at runtime, so it can be understood as a clever, highly optimized interpreter. Which is it?
It's like "it's a plant" or "it's an animal" questions. There are live things that don't quite fit either mold very well: nature is what nature is, and 'classification' of things is a purely human intellectual effort that has its limitations. Even man-made things like 'code' are subject to the same considerations.
Ok; so maybe there is one right answer:
The way JavaScript is processed (say, as of 5 years ago) is called an 'Interpreter'. The way C++ is processed is considered a 'compiler'.
The way IL is processed is simply... a 'JIT'.
CLI(.Net 字节码)具有本机 CPU 所没有的功能,因此 JIT 无疑是一种编译器。然而,与一些人在这里写的相反,大多数优化已经完成。
CLI (.Net bytecode) has features not found in native CPU's, so JIT is most definitively a compiler. Contrary to what some write here most of the optimizations has already been done however.
HTML 不是编程语言,因此很难说它是编译的还是解释的......从“如果编译结果被重用”的角度来看,HTML 不会被任何浏览器编译(它会在页面呈现时被解析)。
旧版浏览器中的 JavaScript 是被解释的(预处理为中间表示,但不是机器代码)。最新版本的浏览器具有 JavaScript JIT 编译器 - 因此现在很难定义它是解释型语言还是编译型语言。
HTML is not programing language, so it is hard to say if it is compiled or interpreted... In sence of "if result of compilation is reused" HTML is not compiled by any browsers (it is parsed any time page is renderd).
JavaScript in older browsers is interpreted (preprocessed into intermediate representation, but not to machine code). Latest versions of browsers have JavaScript JIT compilers - so it is much harder to define if it is interpreted or compiled language now.
JIT(Just In Time)编译器只是一个编译器,而不是一个解释器,因为 JIT 编译器在运行时将某些字节码编译或转换为本机机器代码以获得高性能,但它并不执行指令。
然而,解释器在运行时读取并执行指令。
HTML和Javascript被解释,浏览器直接执行,无需编译。
JIT (Just In Time) Compiler is a compiler only and not an interpreter,because JIT compiler compiles or converts certain pieces of bytecodes to native machine code at run-time for high performance,but it does'nt execute the instructions.
Whereas,an Interpreter reads and executes the instructions at runtime.
HTML and Javascript are interpreted,it is directly executed by browser without compilation.