机器码是否由高级指令生成的,可能比由汇编级指令生成的机器码效率低?

huangapple go评论71阅读模式
英文:

Is machine code of high level instructions might be less efficient than the machine code generated from assembly level instructions

问题

机器码特别依赖于执行它的机器。这意味着机器码的效率取决于机器。但是,如果我们谈论汇编级别和高级语言的效率,那么汇编语言在执行时比高级语言更高效,因为汇编使用更接近机器码的助记符代码或符号。

上面的回答正确吗?

英文:

Machine code is particularly depended on the machine on which it is executed. This means that efficiency machine code depend upon machine. But, if we talk about the efficiency of assembly level and high level languages than assembly languages are more efficient in execution than high level because assembly uses mnemonic codes or symbols which are more closer to machine code.

above answer is correct or not?

答案1

得分: 1

我个人不这么认为。让我们以拥有字节码的Java和C++为例。这两种语言都被视为高级语言,但Java有一个称为字节码的中间层。字节码与体系结构无关,使得Java拥有“一次编写,随处运行”的优势。另一方面,JVM需要一些开销,以将Java类生成字节码。就性能而言,Java字节码相对于C++代码的优越性也是有争议的,因为两者的版本都会被编译回汇编语言。因此,总的来说,我认为你的说法是错误的。关于C++代码和JVM字节码在性能方面的比较,这里有一个很好的参考链接 - https://stackoverflow.com/questions/13611634/c11native-code-vs-javabytecode

英文:

Personally, I don't think so. Let's pick java that has a byte code and C++ for example. Both languages are considered as a high level languages, but java has a middle layer known as a byte code. Byte code is architecture agnostic that gives Java a power of "Write once, run anywhere". On other side, there is an overhead that's required for JVM to produce a bytecode out of java classes. Superiority of java bytecode over c++ code in terms of performance also questionable, because of both versions compiled back to assembler. Thus, in general, I would say that your statement is wrong. Here is a good reference on comparison between C++ code and JVM bytecode in terms of performance - https://stackoverflow.com/questions/13611634/c11native-code-vs-javabytecode

huangapple
  • 本文由 发表于 2020年9月1日 12:49:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63681558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定